Coverage Report

Created: 2026-09-01 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/krb5/src/include/k5-int.h
Line
Count
Source
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/*
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.
6
 *
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
11
 * conditions:
12
 *
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.
17
 *
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
24
 * distribution:
25
 *
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.
32
 *
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
37
 * preserve same.
38
 *
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.
42
 */
43
/*
44
 * Copyright (C) 1998 by the FundsXpress, INC.
45
 *
46
 * All rights reserved.
47
 *
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.
52
 *
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.
63
 *
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.
67
 */
68
69
/*
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.
74
 *
75
 * John Gilmore, Cygnus Support, Sat Jan 21 22:45:52 PST 1995
76
 */
77
78
#ifndef _KRB5_INT_H
79
#define _KRB5_INT_H
80
81
#ifdef KRB5_GENERAL__
82
#error krb5.h included before k5-int.h
83
#endif /* KRB5_GENERAL__ */
84
85
#include "osconf.h"
86
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."
91
#    endif
92
#endif
93
94
/*
95
 * Begin "k5-config.h"
96
 */
97
#ifndef KRB5_CONFIG__
98
#define KRB5_CONFIG__
99
100
/*
101
 * Machine-type definitions: PC Clone 386 running Microloss Windows
102
 */
103
104
#if defined(_MSDOS) || defined(_WIN32)
105
#include "win-mac.h"
106
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 */
112
#endif
113
114
#include "autoconf.h"
115
116
#ifndef KRB5_SYSTYPES__
117
#define KRB5_SYSTYPES__
118
119
#ifdef HAVE_SYS_TYPES_H         /* From autoconf.h */
120
#include <sys/types.h>
121
#else /* HAVE_SYS_TYPES_H */
122
typedef unsigned long   u_long;
123
typedef unsigned int    u_int;
124
typedef unsigned short  u_short;
125
typedef unsigned char   u_char;
126
#endif /* HAVE_SYS_TYPES_H */
127
#endif /* KRB5_SYSTYPES__ */
128
129
130
#include "k5-platform.h"
131
132
#define KRB5_KDB_MAX_LIFE       (60*60*24) /* one day */
133
#define KRB5_KDB_MAX_RLIFE      (60*60*24*7) /* one week */
134
#define KRB5_KDB_EXPIRATION     2145830400 /* Thu Jan  1 00:00:00 2038 UTC */
135
136
/*
137
 * Windows requires a different api interface to each function. Here
138
 * just define it as NULL.
139
 */
140
#ifndef KRB5_CALLCONV
141
#define KRB5_CALLCONV
142
#define KRB5_CALLCONV_C
143
#endif
144
#ifndef O_BINARY
145
#define O_BINARY 0
146
#endif
147
148
/* #define KRB5_OLD_CRYPTO is done in krb5.h */
149
150
#endif /* KRB5_CONFIG__ */
151
152
/*
153
 * End "k5-config.h"
154
 */
155
156
/*
157
 * After loading the configuration definitions, load the Kerberos definitions.
158
 */
159
#include <errno.h>
160
#include "krb5.h"
161
#include <krb5/plugin.h>
162
#include "profile.h"
163
164
#include "port-sockets.h"
165
#include "socket-utils.h"
166
167
/* Get mutex support; currently used only for the replay cache.  */
168
#include "k5-thread.h"
169
170
/* Get error info support.  */
171
#include "k5-err.h"
172
173
/* Get string buffer support. */
174
#include "k5-buf.h"
175
176
/* Define tracing macros. */
177
#include "k5-trace.h"
178
179
/* Profile variables.  Constants are named KRB5_CONF_STRING, where STRING
180
 * matches the variable name.  Keep these alphabetized. */
181
#define KRB5_CONF_ACL_FILE                     "acl_file"
182
#define KRB5_CONF_ADMIN_SERVER                 "admin_server"
183
#define KRB5_CONF_ALLOW_DES3                   "allow_des3"
184
#define KRB5_CONF_ALLOW_RC4                    "allow_rc4"
185
#define KRB5_CONF_ALLOW_WEAK_CRYPTO            "allow_weak_crypto"
186
#define KRB5_CONF_AUTH_TO_LOCAL                "auth_to_local"
187
#define KRB5_CONF_AUTH_TO_LOCAL_NAMES          "auth_to_local_names"
188
#define KRB5_CONF_AUTO_FAST_ARMOR              "auto_fast_armor"
189
#define KRB5_CONF_CANONICALIZE                 "canonicalize"
190
#define KRB5_CONF_CCACHE_TYPE                  "ccache_type"
191
#define KRB5_CONF_CLOCKSKEW                    "clockskew"
192
#define KRB5_CONF_DATABASE_NAME                "database_name"
193
#define KRB5_CONF_DB_MODULE_DIR                "db_module_dir"
194
#define KRB5_CONF_DEBUG                        "debug"
195
#define KRB5_CONF_DEFAULT                      "default"
196
#define KRB5_CONF_DEFAULT_CCACHE_NAME          "default_ccache_name"
197
#define KRB5_CONF_DEFAULT_CLIENT_KEYTAB_NAME   "default_client_keytab_name"
198
#define KRB5_CONF_DEFAULT_DOMAIN               "default_domain"
199
#define KRB5_CONF_DEFAULT_KEYTAB_NAME          "default_keytab_name"
200
#define KRB5_CONF_DEFAULT_PRINCIPAL_EXPIRATION "default_principal_expiration"
201
#define KRB5_CONF_DEFAULT_PRINCIPAL_FLAGS      "default_principal_flags"
202
#define KRB5_CONF_DEFAULT_RCACHE_NAME          "default_rcache_name"
203
#define KRB5_CONF_DEFAULT_REALM                "default_realm"
204
#define KRB5_CONF_DEFAULT_TGS_ENCTYPES         "default_tgs_enctypes"
205
#define KRB5_CONF_DEFAULT_TKT_ENCTYPES         "default_tkt_enctypes"
206
#define KRB5_CONF_DICT_FILE                    "dict_file"
207
#define KRB5_CONF_DISABLE                      "disable"
208
#define KRB5_CONF_DISABLE_ENCRYPTED_TIMESTAMP  "disable_encrypted_timestamp"
209
#define KRB5_CONF_DISABLE_LAST_SUCCESS         "disable_last_success"
210
#define KRB5_CONF_DISABLE_LOCKOUT              "disable_lockout"
211
#define KRB5_CONF_DISABLE_PAC                  "disable_pac"
212
#define KRB5_CONF_DNS_CANONICALIZE_HOSTNAME    "dns_canonicalize_hostname"
213
#define KRB5_CONF_DNS_FALLBACK                 "dns_fallback"
214
#define KRB5_CONF_DNS_LOOKUP_KDC               "dns_lookup_kdc"
215
#define KRB5_CONF_DNS_LOOKUP_REALM             "dns_lookup_realm"
216
#define KRB5_CONF_DNS_URI_LOOKUP               "dns_uri_lookup"
217
#define KRB5_CONF_DOMAIN_REALM                 "domain_realm"
218
#define KRB5_CONF_ENABLE_ONLY                  "enable_only"
219
#define KRB5_CONF_ENCRYPTED_CHALLENGE_INDICATOR "encrypted_challenge_indicator"
220
#define KRB5_CONF_ENFORCE_OK_AS_DELEGATE       "enforce_ok_as_delegate"
221
#define KRB5_CONF_ERR_FMT                      "err_fmt"
222
#define KRB5_CONF_EXTRA_ADDRESSES              "extra_addresses"
223
#define KRB5_CONF_FORWARDABLE                  "forwardable"
224
#define KRB5_CONF_HOST_BASED_SERVICES          "host_based_services"
225
#define KRB5_CONF_HTTP_ANCHORS                 "http_anchors"
226
#define KRB5_CONF_IGNORE_ACCEPTOR_HOSTNAME     "ignore_acceptor_hostname"
227
#define KRB5_CONF_IPROP_ENABLE                 "iprop_enable"
228
#define KRB5_CONF_IPROP_LISTEN                 "iprop_listen"
229
#define KRB5_CONF_IPROP_LOGFILE                "iprop_logfile"
230
#define KRB5_CONF_IPROP_MASTER_ULOGSIZE        "iprop_master_ulogsize"
231
#define KRB5_CONF_IPROP_PORT                   "iprop_port"
232
#define KRB5_CONF_IPROP_RESYNC_TIMEOUT         "iprop_resync_timeout"
233
#define KRB5_CONF_IPROP_REPLICA_POLL           "iprop_replica_poll"
234
#define KRB5_CONF_IPROP_SLAVE_POLL             "iprop_slave_poll"
235
#define KRB5_CONF_IPROP_ULOGSIZE               "iprop_ulogsize"
236
#define KRB5_CONF_K5LOGIN_AUTHORITATIVE        "k5login_authoritative"
237
#define KRB5_CONF_K5LOGIN_DIRECTORY            "k5login_directory"
238
#define KRB5_CONF_KADMIND_LISTEN               "kadmind_listen"
239
#define KRB5_CONF_KADMIND_PORT                 "kadmind_port"
240
#define KRB5_CONF_KCM_MACH_SERVICE             "kcm_mach_service"
241
#define KRB5_CONF_KCM_SOCKET                   "kcm_socket"
242
#define KRB5_CONF_KDC                          "kdc"
243
#define KRB5_CONF_KDCDEFAULTS                  "kdcdefaults"
244
#define KRB5_CONF_KDC_DEFAULT_OPTIONS          "kdc_default_options"
245
#define KRB5_CONF_KDC_LISTEN                   "kdc_listen"
246
#define KRB5_CONF_KDC_MAX_DGRAM_REPLY_SIZE     "kdc_max_dgram_reply_size"
247
#define KRB5_CONF_KDC_PORTS                    "kdc_ports"
248
#define KRB5_CONF_KDC_TCP_PORTS                "kdc_tcp_ports"
249
#define KRB5_CONF_KDC_TCP_LISTEN               "kdc_tcp_listen"
250
#define KRB5_CONF_KDC_TCP_LISTEN_BACKLOG       "kdc_tcp_listen_backlog"
251
#define KRB5_CONF_KDC_TIMESYNC                 "kdc_timesync"
252
#define KRB5_CONF_KDC_UNIXSOCK_LISTEN          "kdc_unixsock_listen"
253
#define KRB5_CONF_KEY_STASH_FILE               "key_stash_file"
254
#define KRB5_CONF_KPASSWD_LISTEN               "kpasswd_listen"
255
#define KRB5_CONF_KPASSWD_PORT                 "kpasswd_port"
256
#define KRB5_CONF_KPASSWD_SERVER               "kpasswd_server"
257
#define KRB5_CONF_KRB524_SERVER                "krb524_server"
258
#define KRB5_CONF_LDAP_CONNS_PER_SERVER        "ldap_conns_per_server"
259
#define KRB5_CONF_LDAP_KADMIND_DN              "ldap_kadmind_dn"
260
#define KRB5_CONF_LDAP_KADMIND_SASL_AUTHCID    "ldap_kadmind_sasl_authcid"
261
#define KRB5_CONF_LDAP_KADMIND_SASL_AUTHZID    "ldap_kadmind_sasl_authzid"
262
#define KRB5_CONF_LDAP_KADMIND_SASL_MECH       "ldap_kadmind_sasl_mech"
263
#define KRB5_CONF_LDAP_KADMIND_SASL_REALM      "ldap_kadmind_sasl_realm"
264
#define KRB5_CONF_LDAP_KDC_DN                  "ldap_kdc_dn"
265
#define KRB5_CONF_LDAP_KDC_SASL_AUTHCID        "ldap_kdc_sasl_authcid"
266
#define KRB5_CONF_LDAP_KDC_SASL_AUTHZID        "ldap_kdc_sasl_authzid"
267
#define KRB5_CONF_LDAP_KDC_SASL_MECH           "ldap_kdc_sasl_mech"
268
#define KRB5_CONF_LDAP_KDC_SASL_REALM          "ldap_kdc_sasl_realm"
269
#define KRB5_CONF_LDAP_KERBEROS_CONTAINER_DN   "ldap_kerberos_container_dn"
270
#define KRB5_CONF_LDAP_SERVERS                 "ldap_servers"
271
#define KRB5_CONF_LDAP_SERVICE_PASSWORD_FILE   "ldap_service_password_file"
272
#define KRB5_CONF_LIBDEFAULTS                  "libdefaults"
273
#define KRB5_CONF_LOGGING                      "logging"
274
#define KRB5_CONF_MAPSIZE                      "mapsize"
275
#define KRB5_CONF_MASTER_KDC                   "master_kdc"
276
#define KRB5_CONF_MASTER_KEY_NAME              "master_key_name"
277
#define KRB5_CONF_MASTER_KEY_TYPE              "master_key_type"
278
#define KRB5_CONF_MAX_LIFE                     "max_life"
279
#define KRB5_CONF_MAX_READERS                  "max_readers"
280
#define KRB5_CONF_MAX_RENEWABLE_LIFE           "max_renewable_life"
281
#define KRB5_CONF_MODULE                       "module"
282
#define KRB5_CONF_NOADDRESSES                  "noaddresses"
283
#define KRB5_CONF_NOSYNC                       "nosync"
284
#define KRB5_CONF_NO_HOST_REFERRAL             "no_host_referral"
285
#define KRB5_CONF_PERMITTED_ENCTYPES           "permitted_enctypes"
286
#define KRB5_CONF_PLUGINS                      "plugins"
287
#define KRB5_CONF_PLUGIN_BASE_DIR              "plugin_base_dir"
288
#define KRB5_CONF_PREFERRED_PREAUTH_TYPES      "preferred_preauth_types"
289
#define KRB5_CONF_PRIMARY_KDC                  "primary_kdc"
290
#define KRB5_CONF_PROXIABLE                    "proxiable"
291
#define KRB5_CONF_QUALIFY_SHORTNAME            "qualify_shortname"
292
#define KRB5_CONF_RDNS                         "rdns"
293
#define KRB5_CONF_REALMS                       "realms"
294
#define KRB5_CONF_REALM_TRY_DOMAINS            "realm_try_domains"
295
#define KRB5_CONF_REJECT_BAD_TRANSIT           "reject_bad_transit"
296
#define KRB5_CONF_RENEW_LIFETIME               "renew_lifetime"
297
#define KRB5_CONF_RESTRICT_ANONYMOUS_TO_TGT    "restrict_anonymous_to_tgt"
298
#define KRB5_CONF_SITENAME                     "sitename"
299
#define KRB5_CONF_SUPPORTED_ENCTYPES           "supported_enctypes"
300
#define KRB5_CONF_SPAKE_PREAUTH_INDICATOR      "spake_preauth_indicator"
301
#define KRB5_CONF_SPAKE_PREAUTH_KDC_CHALLENGE  "spake_preauth_kdc_challenge"
302
#define KRB5_CONF_SPAKE_PREAUTH_GROUPS         "spake_preauth_groups"
303
#define KRB5_CONF_REQUEST_TIMEOUT              "request_timeout"
304
#define KRB5_CONF_TICKET_LIFETIME              "ticket_lifetime"
305
#define KRB5_CONF_UDP_PREFERENCE_LIMIT         "udp_preference_limit"
306
#define KRB5_CONF_UNLOCKITER                   "unlockiter"
307
#define KRB5_CONF_V4_INSTANCE_CONVERT          "v4_instance_convert"
308
#define KRB5_CONF_V4_REALM                     "v4_realm"
309
#define KRB5_CONF_VERIFY_AP_REQ_NOFAIL         "verify_ap_req_nofail"
310
#define KRB5_CONF_CLIENT_AWARE_GSS_BINDINGS    "client_aware_channel_bindings"
311
312
/* Cache configuration variables */
313
#define KRB5_CC_CONF_FAST_AVAIL                "fast_avail"
314
#define KRB5_CC_CONF_PA_CONFIG_DATA            "pa_config_data"
315
#define KRB5_CC_CONF_PA_TYPE                   "pa_type"
316
#define KRB5_CC_CONF_PROXY_IMPERSONATOR        "proxy_impersonator"
317
#define KRB5_CC_CONF_REFRESH_TIME              "refresh_time"
318
#define KRB5_CC_CONF_START_REALM               "start_realm"
319
320
/* Error codes used in KRB_ERROR protocol messages.
321
   Return values of library routines are based on a different error table
322
   (which allows non-ambiguous error codes between subsystems) */
323
324
/* KDC errors */
325
#define KDC_ERR_NONE                    0 /* No error */
326
#define KDC_ERR_NAME_EXP                1 /* Client's entry in DB expired */
327
#define KDC_ERR_SERVICE_EXP             2 /* Server's entry in DB expired */
328
#define KDC_ERR_BAD_PVNO                3 /* Requested pvno not supported */
329
#define KDC_ERR_C_OLD_MAST_KVNO         4 /* C's key encrypted in old master */
330
#define KDC_ERR_S_OLD_MAST_KVNO         5 /* S's key encrypted in old master */
331
#define KDC_ERR_C_PRINCIPAL_UNKNOWN     6 /* Client not found in Kerberos DB */
332
#define KDC_ERR_S_PRINCIPAL_UNKNOWN     7 /* Server not found in Kerberos DB */
333
#define KDC_ERR_PRINCIPAL_NOT_UNIQUE    8 /* Multiple entries in Kerberos DB */
334
#define KDC_ERR_NULL_KEY                9 /* The C or S has a null key */
335
#define KDC_ERR_CANNOT_POSTDATE         10 /* Tkt ineligible for postdating */
336
#define KDC_ERR_NEVER_VALID             11 /* Requested starttime > endtime */
337
#define KDC_ERR_POLICY                  12 /* KDC policy rejects request */
338
#define KDC_ERR_BADOPTION               13 /* KDC can't do requested opt. */
339
#define KDC_ERR_ENCTYPE_NOSUPP          14 /* No support for encryption type */
340
#define KDC_ERR_SUMTYPE_NOSUPP          15 /* No support for checksum type */
341
#define KDC_ERR_PADATA_TYPE_NOSUPP      16 /* No support for padata type */
342
#define KDC_ERR_TRTYPE_NOSUPP           17 /* No support for transited type */
343
#define KDC_ERR_CLIENT_REVOKED          18 /* C's creds have been revoked */
344
#define KDC_ERR_SERVICE_REVOKED         19 /* S's creds have been revoked */
345
#define KDC_ERR_TGT_REVOKED             20 /* TGT has been revoked */
346
#define KDC_ERR_CLIENT_NOTYET           21 /* C not yet valid */
347
#define KDC_ERR_SERVICE_NOTYET          22 /* S not yet valid */
348
#define KDC_ERR_KEY_EXP                 23 /* Password has expired */
349
#define KDC_ERR_PREAUTH_FAILED          24 /* Preauthentication failed */
350
#define KDC_ERR_PREAUTH_REQUIRED        25 /* Additional preauthentication */
351
                                           /* required */
352
#define KDC_ERR_SERVER_NOMATCH          26 /* Requested server and */
353
                                           /* ticket don't match*/
354
#define KDC_ERR_MUST_USE_USER2USER      27 /* Server principal valid for */
355
                                           /*   user2user only */
356
#define KDC_ERR_PATH_NOT_ACCEPTED       28 /* KDC policy rejected transited */
357
                                           /*   path */
358
#define KDC_ERR_SVC_UNAVAILABLE         29 /* A service is not
359
                                            * available that is
360
                                            * required to process the
361
                                            * request */
362
/* Application errors */
363
#define KRB_AP_ERR_BAD_INTEGRITY 31     /* Decrypt integrity check failed */
364
#define KRB_AP_ERR_TKT_EXPIRED  32      /* Ticket expired */
365
#define KRB_AP_ERR_TKT_NYV      33      /* Ticket not yet valid */
366
#define KRB_AP_ERR_REPEAT       34      /* Request is a replay */
367
#define KRB_AP_ERR_NOT_US       35      /* The ticket isn't for us */
368
#define KRB_AP_ERR_BADMATCH     36      /* Ticket/authenticator don't match */
369
#define KRB_AP_ERR_SKEW         37      /* Clock skew too great */
370
#define KRB_AP_ERR_BADADDR      38      /* Incorrect net address */
371
#define KRB_AP_ERR_BADVERSION   39      /* Protocol version mismatch */
372
#define KRB_AP_ERR_MSG_TYPE     40      /* Invalid message type */
373
#define KRB_AP_ERR_MODIFIED     41      /* Message stream modified */
374
#define KRB_AP_ERR_BADORDER     42      /* Message out of order */
375
#define KRB_AP_ERR_BADKEYVER    44      /* Key version is not available */
376
#define KRB_AP_ERR_NOKEY        45      /* Service key not available */
377
#define KRB_AP_ERR_MUT_FAIL     46      /* Mutual authentication failed */
378
#define KRB_AP_ERR_BADDIRECTION 47      /* Incorrect message direction */
379
#define KRB_AP_ERR_METHOD       48      /* Alternative authentication */
380
                                        /* method required */
381
#define KRB_AP_ERR_BADSEQ       49      /* Incorrect sequence numnber */
382
                                        /* in message */
383
#define KRB_AP_ERR_INAPP_CKSUM  50      /* Inappropriate type of */
384
                                        /* checksum in message */
385
#define KRB_AP_PATH_NOT_ACCEPTED 51     /* Policy rejects transited path */
386
#define KRB_ERR_RESPONSE_TOO_BIG 52     /* Response too big for UDP, */
387
                                        /*   retry with TCP */
388
389
/* other errors */
390
#define KRB_ERR_GENERIC         60      /* Generic error (description */
391
                                        /* in e-text) */
392
#define KRB_ERR_FIELD_TOOLONG   61      /* Field is too long for impl. */
393
394
/* PKINIT server-reported errors */
395
#define KDC_ERR_CLIENT_NOT_TRUSTED              62 /* client cert not trusted */
396
#define KDC_ERR_KDC_NOT_TRUSTED                 63
397
#define KDC_ERR_INVALID_SIG                     64 /* client signature verify failed */
398
#define KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED  65 /* invalid Diffie-Hellman parameters */
399
#define KDC_ERR_CERTIFICATE_MISMATCH            66
400
#define KRB_AP_ERR_NO_TGT                       67
401
#define KDC_ERR_WRONG_REALM                     68
402
#define KRB_AP_ERR_USER_TO_USER_REQUIRED        69
403
#define KDC_ERR_CANT_VERIFY_CERTIFICATE         70 /* client cert not verifiable to */
404
                                                   /* trusted root cert */
405
#define KDC_ERR_INVALID_CERTIFICATE             71 /* client cert had invalid signature */
406
#define KDC_ERR_REVOKED_CERTIFICATE             72 /* client cert was revoked */
407
#define KDC_ERR_REVOCATION_STATUS_UNKNOWN       73 /* client cert revoked, reason unknown */
408
#define KDC_ERR_REVOCATION_STATUS_UNAVAILABLE   74
409
#define KDC_ERR_CLIENT_NAME_MISMATCH            75 /* mismatch between client cert and */
410
                                                   /* principal name */
411
#define KDC_ERR_INCONSISTENT_KEY_PURPOSE        77 /* bad extended key use */
412
#define KDC_ERR_DIGEST_IN_CERT_NOT_ACCEPTED     78 /* bad digest algorithm in client cert */
413
#define KDC_ERR_PA_CHECKSUM_MUST_BE_INCLUDED    79 /* missing paChecksum in PA-PK-AS-REQ */
414
#define KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED 80 /* bad digest algorithm in SignedData */
415
#define KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED 81
416
#define KRB_AP_ERR_IAKERB_KDC_NOT_FOUND         85 /* The IAKERB proxy could
417
                                                      not find a KDC */
418
#define KRB_AP_ERR_IAKERB_KDC_NO_RESPONSE       86 /* The KDC did not respond
419
                                                      to the IAKERB proxy */
420
#define KDC_ERR_PREAUTH_EXPIRED                 90 /* RFC 6113 */
421
#define KDC_ERR_MORE_PREAUTH_DATA_REQUIRED      91 /* RFC 6113 */
422
#define KRB_ERR_MAX 127 /* err table base max offset for protocol err codes */
423
424
/*
425
 * A null-terminated array of this structure is returned by the KDC as
426
 * the data part of the ETYPE_INFO preauth type.  It informs the
427
 * client which encryption types are supported.
428
 * The  same data structure is used by both etype-info and etype-info2
429
 * but s2kparams must be null when encoding etype-info.
430
 */
431
typedef struct _krb5_etype_info_entry {
432
    krb5_magic      magic;
433
    krb5_enctype    etype;
434
    unsigned int    length;
435
    krb5_octet      *salt;
436
    krb5_data s2kparams;
437
} krb5_etype_info_entry;
438
439
/*
440
 *  This is essentially -1 without sign extension which can screw up
441
 *  comparisons on 64 bit machines. If the length is this value, then
442
 *  the salt data is not present. This is to distinguish between not
443
 *  being set and being of 0 length.
444
 */
445
#define KRB5_ETYPE_NO_SALT VALID_UINT_BITS
446
447
typedef krb5_etype_info_entry ** krb5_etype_info;
448
449
/* RFC 4537 */
450
typedef struct _krb5_etype_list {
451
    int             length;
452
    krb5_enctype    *etypes;
453
} krb5_etype_list;
454
455
/* sam_type values -- informational only */
456
#define PA_SAM_TYPE_ENIGMA     1   /*  Enigma Logic */
457
#define PA_SAM_TYPE_DIGI_PATH  2   /*  Digital Pathways */
458
#define PA_SAM_TYPE_SKEY_K0    3   /*  S/key where  KDC has key 0 */
459
#define PA_SAM_TYPE_SKEY       4   /*  Traditional S/Key */
460
#define PA_SAM_TYPE_SECURID    5   /*  Security Dynamics */
461
#define PA_SAM_TYPE_CRYPTOCARD 6   /*  CRYPTOCard */
462
#if 1 /* XXX need to figure out who has which numbers assigned */
463
#define PA_SAM_TYPE_ACTIVCARD_DEC  6   /*  ActivCard decimal mode */
464
#define PA_SAM_TYPE_ACTIVCARD_HEX  7   /*  ActivCard hex mode */
465
#define PA_SAM_TYPE_DIGI_PATH_HEX  8   /*  Digital Pathways hex mode */
466
#endif
467
#define PA_SAM_TYPE_EXP_BASE    128 /* experimental */
468
#define PA_SAM_TYPE_GRAIL               (PA_SAM_TYPE_EXP_BASE+0) /* testing */
469
#define PA_SAM_TYPE_SECURID_PREDICT     (PA_SAM_TYPE_EXP_BASE+1) /* special */
470
471
typedef struct _krb5_sam_challenge_2 {
472
    krb5_data       sam_challenge_2_body;
473
    krb5_checksum   **sam_cksum;            /* Array of checksums */
474
} krb5_sam_challenge_2;
475
476
typedef struct _krb5_sam_challenge_2_body {
477
    krb5_magic      magic;
478
    krb5_int32      sam_type; /* information */
479
    krb5_flags      sam_flags; /* KRB5_SAM_* values */
480
    krb5_data       sam_type_name;
481
    krb5_data       sam_track_id;
482
    krb5_data       sam_challenge_label;
483
    krb5_data       sam_challenge;
484
    krb5_data       sam_response_prompt;
485
    krb5_data       sam_pk_for_sad;
486
    krb5_int32      sam_nonce;
487
    krb5_enctype    sam_etype;
488
} krb5_sam_challenge_2_body;
489
490
typedef struct _krb5_sam_response_2 {
491
    krb5_magic      magic;
492
    krb5_int32      sam_type; /* informational */
493
    krb5_flags      sam_flags; /* KRB5_SAM_* values */
494
    krb5_data       sam_track_id; /* copied */
495
    krb5_enc_data   sam_enc_nonce_or_sad; /* krb5_enc_sam_response_enc */
496
    krb5_int32      sam_nonce;
497
} krb5_sam_response_2;
498
499
typedef struct _krb5_enc_sam_response_enc_2 {
500
    krb5_magic      magic;
501
    krb5_int32      sam_nonce;
502
    krb5_data       sam_sad;
503
} krb5_enc_sam_response_enc_2;
504
505
/*
506
 * Keep the pkinit definitions in a separate file so that the plugin
507
 * only has to include k5-int-pkinit.h rather than k5-int.h
508
 */
509
510
#include "k5-int-pkinit.h"
511
512
#define KRB5_OTP_FLAG_NEXTOTP        0x40000000
513
#define KRB5_OTP_FLAG_COMBINE        0x20000000
514
#define KRB5_OTP_FLAG_COLLECT_PIN    0x10000000
515
#define KRB5_OTP_FLAG_NO_COLLECT_PIN 0x08000000
516
#define KRB5_OTP_FLAG_ENCRYPT_NONCE  0x04000000
517
#define KRB5_OTP_FLAG_SEPARATE_PIN   0x02000000
518
#define KRB5_OTP_FLAG_CHECK_DIGIT    0x01000000
519
520
#define KRB5_OTP_FORMAT_DECIMAL      0x00000000
521
#define KRB5_OTP_FORMAT_HEXADECIMAL  0x00000001
522
#define KRB5_OTP_FORMAT_ALPHANUMERIC 0x00000002
523
#define KRB5_OTP_FORMAT_BINARY       0x00000003
524
#define KRB5_OTP_FORMAT_BASE64       0x00000004
525
526
typedef struct _krb5_otp_tokeninfo {
527
    krb5_flags flags;
528
    krb5_data vendor;
529
    krb5_data challenge;
530
    krb5_int32 length;          /* -1 for unspecified */
531
    krb5_int32 format;          /* -1 for unspecified */
532
    krb5_data token_id;
533
    krb5_data alg_id;
534
    krb5_algorithm_identifier **supported_hash_alg;
535
    krb5_int32 iteration_count; /* -1 for unspecified */
536
} krb5_otp_tokeninfo;
537
538
typedef struct _krb5_pa_otp_challenge {
539
    krb5_data nonce;
540
    krb5_data service;
541
    krb5_otp_tokeninfo **tokeninfo;
542
    krb5_data salt;
543
    krb5_data s2kparams;
544
} krb5_pa_otp_challenge;
545
546
typedef struct _krb5_pa_otp_req {
547
    krb5_int32 flags;
548
    krb5_data nonce;
549
    krb5_enc_data enc_data;
550
    krb5_algorithm_identifier *hash_alg;
551
    krb5_int32 iteration_count; /* -1 for unspecified */
552
    krb5_data otp_value;
553
    krb5_data pin;
554
    krb5_data challenge;
555
    krb5_timestamp time;
556
    krb5_data counter;
557
    krb5_int32 format;          /* -1 for unspecified */
558
    krb5_data token_id;
559
    krb5_data alg_id;
560
    krb5_data vendor;
561
} krb5_pa_otp_req;
562
563
typedef struct _krb5_kkdcp_message {
564
    krb5_data kerb_message;
565
    krb5_data target_domain;
566
    krb5_int32 dclocator_hint;
567
} krb5_kkdcp_message;
568
569
/* Plain text of an encrypted PA-FX-COOKIE value produced by the KDC. */
570
typedef struct _krb5_secure_cookie {
571
    time_t time;
572
    krb5_pa_data **data;
573
} krb5_secure_cookie;
574
575
typedef struct _krb5_pa_pac_options {
576
    krb5_flags options;
577
} krb5_pa_pac_options;
578
579
/* In PAC options, indicates Resource-Based Constrained Delegation support. */
580
#define KRB5_PA_PAC_OPTIONS_RBCD 0x10000000
581
582
#include <stdlib.h>
583
#include <string.h>
584
585
#ifndef HAVE_STRDUP
586
extern char *strdup (const char *);
587
#endif
588
589
#ifdef HAVE_UNISTD_H
590
#include <unistd.h>
591
#endif
592
593
#ifdef HAVE_SYS_TIME_H
594
#include <sys/time.h>
595
#endif
596
#include <time.h>
597
598
#ifdef HAVE_SYS_STAT_H
599
#include <sys/stat.h>                   /* struct stat, stat() */
600
#endif
601
602
#ifdef HAVE_SYS_PARAM_H
603
#include <sys/param.h>                  /* MAXPATHLEN */
604
#endif
605
606
#ifdef HAVE_SYS_FILE_H
607
#include <sys/file.h>                   /* prototypes for file-related
608
                                           syscalls; flags for open &
609
                                           friends */
610
#endif
611
612
#ifdef HAVE_FCNTL_H
613
#include <fcntl.h>
614
#endif
615
616
#include <stdio.h>
617
618
#include "k5-gmt_mktime.h"
619
620
/* libos.spec */
621
krb5_error_code krb5_lock_file(krb5_context, int, int);
622
krb5_error_code krb5_unlock_file(krb5_context, int);
623
krb5_error_code krb5_sendto_kdc(krb5_context, const krb5_data *,
624
                                const krb5_data *, krb5_data *, int *, int);
625
626
krb5_error_code krb5int_init_context_kdc(krb5_context *);
627
628
struct derived_key {
629
    krb5_data constant;
630
    krb5_key dkey;
631
    struct derived_key *next;
632
};
633
634
/* Internal structure of an opaque key identifier */
635
struct krb5_key_st {
636
    krb5_keyblock keyblock;
637
    int refcount;
638
    struct derived_key *derived;
639
    /*
640
     * Cache of data private to the cipher implementation, which we
641
     * don't want to have to recompute for every operation.  This may
642
     * include key schedules, iteration counts, etc.
643
     *
644
     * The cipher implementation is responsible for setting this up
645
     * whenever needed, and the enc_provider key_cleanup method must
646
     * then be provided to dispose of it.
647
     */
648
    void *cache;
649
};
650
651
krb5_error_code
652
krb5int_arcfour_gsscrypt(const krb5_keyblock *keyblock, krb5_keyusage usage,
653
                         const krb5_data *kd_data, krb5_crypto_iov *data,
654
                         size_t num_data);
655
656
#define K5_SHA256_HASHLEN (256 / 8)
657
658
/* Write the SHA-256 hash of in (containing n elements) to out. */
659
krb5_error_code
660
k5_sha256(const krb5_data *in, size_t n, uint8_t out[K5_SHA256_HASHLEN]);
661
662
/* Convenience function: zap and free ptr if it is non-NULL. */
663
static inline void
664
zapfree(void *ptr, size_t len)
665
0
{
666
0
    if (ptr != NULL) {
667
0
        zap(ptr, len);
668
0
        free(ptr);
669
0
    }
670
0
}
Unexecuted instantiation: fuzz_des.c:zapfree
Unexecuted instantiation: f_cksum.c:zapfree
Unexecuted instantiation: f_tables.c:zapfree
Unexecuted instantiation: key_sched.c:zapfree
Unexecuted instantiation: weak_key.c:zapfree
Unexecuted instantiation: f_parity.c:zapfree
Unexecuted instantiation: f_sched.c:zapfree
671
672
/* Convenience function: zap and free zero-terminated str if it is non-NULL. */
673
static inline void
674
zapfreestr(void *str)
675
0
{
676
0
    if (str != NULL) {
677
0
        zap(str, strlen((char *)str));
678
0
        free(str);
679
0
    }
680
0
}
Unexecuted instantiation: fuzz_des.c:zapfreestr
Unexecuted instantiation: f_cksum.c:zapfreestr
Unexecuted instantiation: f_tables.c:zapfreestr
Unexecuted instantiation: key_sched.c:zapfreestr
Unexecuted instantiation: weak_key.c:zapfreestr
Unexecuted instantiation: f_parity.c:zapfreestr
Unexecuted instantiation: f_sched.c:zapfreestr
681
682
/* Convenience function: zap and free krb5_data pointer if it is non-NULL. */
683
static inline void
684
zapfreedata(krb5_data *data)
685
0
{
686
0
    if (data != NULL) {
687
0
        zapfree(data->data, data->length);
688
0
        free(data);
689
0
    }
690
0
}
Unexecuted instantiation: fuzz_des.c:zapfreedata
Unexecuted instantiation: f_cksum.c:zapfreedata
Unexecuted instantiation: f_tables.c:zapfreedata
Unexecuted instantiation: key_sched.c:zapfreedata
Unexecuted instantiation: weak_key.c:zapfreedata
Unexecuted instantiation: f_parity.c:zapfreedata
Unexecuted instantiation: f_sched.c:zapfreedata
691
692
void krb5int_c_free_keyblock(krb5_context, krb5_keyblock *key);
693
void krb5int_c_free_keyblock_contents(krb5_context, krb5_keyblock *);
694
krb5_error_code krb5int_c_init_keyblock(krb5_context, krb5_enctype enctype,
695
                                        size_t length, krb5_keyblock **out);
696
krb5_error_code krb5int_c_copy_keyblock(krb5_context context,
697
                                        const krb5_keyblock *from,
698
                                        krb5_keyblock **to);
699
krb5_error_code krb5int_c_copy_keyblock_contents(krb5_context context,
700
                                                 const krb5_keyblock *from,
701
                                                 krb5_keyblock *to);
702
703
krb5_error_code k5_us_timeofday(krb5_timestamp *, krb5_int32 *);
704
krb5_error_code krb5_crypto_us_timeofday(krb5_timestamp *, krb5_int32 *);
705
706
/*
707
 * End "los-proto.h"
708
 */
709
710
typedef struct _krb5_os_context {
711
    krb5_magic              magic;
712
    krb5_int32              time_offset;
713
    krb5_int32              usec_offset;
714
    krb5_int32              os_flags;
715
    char *                  default_ccname;
716
} *krb5_os_context;
717
718
/*
719
 * Flags for the os_flags field
720
 *
721
 * KRB5_OS_TOFFSET_VALID means that the time offset fields are valid.
722
 * The intention is that this facility to correct the system clocks so
723
 * that they reflect the "real" time, for systems where for some
724
 * reason we can't set the system clock.  Instead we calculate the
725
 * offset between the system time and real time, and store the offset
726
 * in the os context so that we can correct the system clock as necessary.
727
 *
728
 * KRB5_OS_TOFFSET_TIME means that the time offset fields should be
729
 * returned as the time by the krb5 time routines.  This should only
730
 * be used for testing purposes (obviously!)
731
 */
732
#define KRB5_OS_TOFFSET_VALID   1
733
#define KRB5_OS_TOFFSET_TIME    2
734
735
/* lock mode flags */
736
#define KRB5_LOCKMODE_SHARED    0x0001
737
#define KRB5_LOCKMODE_EXCLUSIVE 0x0002
738
#define KRB5_LOCKMODE_DONTBLOCK 0x0004
739
#define KRB5_LOCKMODE_UNLOCK    0x0008
740
741
/*
742
 * Begin "preauth.h"
743
 *
744
 * (Originally written by Glen Machin at Sandia Labs.)
745
 */
746
/*
747
 * Sandia National Laboratories also makes no representations about the
748
 * suitability of the modifications, or additions to this software for
749
 * any purpose.  It is provided "as is" without express or implied warranty.
750
 */
751
#ifndef KRB5_PREAUTH__
752
#define KRB5_PREAUTH__
753
754
typedef struct _krb5_pa_enc_ts {
755
    krb5_timestamp      patimestamp;
756
    krb5_int32          pausec;
757
} krb5_pa_enc_ts;
758
759
typedef struct _krb5_pa_for_user {
760
    krb5_principal      user;
761
    krb5_checksum       cksum;
762
    krb5_data           auth_package;
763
} krb5_pa_for_user;
764
765
typedef struct _krb5_s4u_userid {
766
    krb5_int32          nonce;
767
    krb5_principal      user;
768
    krb5_data           subject_cert;
769
    krb5_flags          options;
770
} krb5_s4u_userid;
771
772
#define KRB5_S4U_OPTS_CHECK_LOGON_HOURS         0x40000000 /* check logon hour restrictions */
773
#define KRB5_S4U_OPTS_USE_REPLY_KEY_USAGE       0x20000000 /* sign with usage 27 instead of 26 */
774
775
typedef struct _krb5_pa_s4u_x509_user {
776
    krb5_s4u_userid     user_id;
777
    krb5_checksum       cksum;
778
} krb5_pa_s4u_x509_user;
779
780
enum {
781
    KRB5_FAST_ARMOR_AP_REQUEST = 0x1
782
};
783
784
typedef struct _krb5_fast_armor {
785
    krb5_int32 armor_type;
786
    krb5_data armor_value;
787
} krb5_fast_armor;
788
typedef struct _krb5_fast_armored_req {
789
    krb5_magic magic;
790
    krb5_fast_armor *armor;
791
    krb5_checksum req_checksum;
792
    krb5_enc_data enc_part;
793
} krb5_fast_armored_req;
794
795
typedef struct _krb5_fast_req {
796
    krb5_magic magic;
797
    krb5_flags fast_options;
798
    /* padata from req_body is used*/
799
    krb5_kdc_req *req_body;
800
} krb5_fast_req;
801
802
/* Bits 0-15 are critical in FAST options (RFC 6113 section 7.3). */
803
#define UNSUPPORTED_CRITICAL_FAST_OPTIONS   0xbfff0000
804
#define KRB5_FAST_OPTION_HIDE_CLIENT_NAMES  0x40000000
805
806
typedef struct _krb5_fast_finished {
807
    krb5_timestamp timestamp;
808
    krb5_int32 usec;
809
    krb5_principal client;
810
    krb5_checksum ticket_checksum;
811
} krb5_fast_finished;
812
813
typedef struct _krb5_fast_response {
814
    krb5_magic magic;
815
    krb5_pa_data **padata;
816
    krb5_keyblock *strengthen_key;
817
    krb5_fast_finished *finished;
818
    krb5_int32 nonce;
819
} krb5_fast_response;
820
821
typedef struct _krb5_ad_kdcissued {
822
    krb5_checksum ad_checksum;
823
    krb5_principal i_principal;
824
    krb5_authdata **elements;
825
} krb5_ad_kdcissued;
826
827
typedef struct _krb5_iakerb_header {
828
    krb5_data target_realm;
829
    krb5_data *cookie;
830
} krb5_iakerb_header;
831
832
typedef struct _krb5_iakerb_finished {
833
    krb5_checksum checksum;
834
} krb5_iakerb_finished;
835
836
typedef struct _krb5_verifier_mac {
837
    krb5_principal princ;
838
    krb5_kvno kvno;
839
    krb5_enctype enctype;
840
    krb5_checksum checksum;
841
} krb5_verifier_mac;
842
843
/*
844
 * AD-CAMMAC's other-verifiers field is a sequence of Verifier, which is an
845
 * extensible choice with only one selection, Verifier-MAC.  For the time being
846
 * we will represent this field directly as an array of krb5_verifier_mac.
847
 * That will have to change if other selections are added.
848
 */
849
typedef struct _krb5_cammac {
850
    krb5_authdata **elements;
851
    krb5_verifier_mac *kdc_verifier;
852
    krb5_verifier_mac *svc_verifier;
853
    krb5_verifier_mac **other_verifiers;
854
} krb5_cammac;
855
856
void krb5_free_etype_info(krb5_context, krb5_etype_info);
857
858
krb5_pa_data *
859
krb5int_find_pa_data(krb5_context, krb5_pa_data *const *, krb5_preauthtype);
860
/* Does not return a copy; original padata sequence responsible for freeing*/
861
862
/* Allocate a pa-data object with uninitialized contents of size len.  If len
863
 * is 0, set the contents field to NULL. */
864
krb5_error_code
865
k5_alloc_pa_data(krb5_preauthtype pa_type, size_t len, krb5_pa_data **out);
866
867
/* Free a single pa-data object. */
868
void
869
k5_free_pa_data_element(krb5_pa_data *pa);
870
871
/* Without copying, add single element *pa to *list, reallocating as necessary.
872
 * If *list is NULL, allocate a new list.  Set *pa to NULL on success. */
873
krb5_error_code
874
k5_add_pa_data_element(krb5_pa_data ***list, krb5_pa_data **pa);
875
876
/* Without copying, add a pa-data element of type pa_type to *list with the
877
 * contents in data.  Set *data to empty_data() on success. */
878
krb5_error_code
879
k5_add_pa_data_from_data(krb5_pa_data ***list, krb5_preauthtype pa_type,
880
                         krb5_data *data);
881
882
/* Add an empty pa-data element of type pa_type to *list. */
883
krb5_error_code
884
k5_add_empty_pa_data(krb5_pa_data ***list, krb5_preauthtype pa_type);
885
886
#endif /* KRB5_PREAUTH__ */
887
/*
888
 * End "preauth.h"
889
 */
890
891
krb5_error_code
892
krb5int_copy_data_contents(krb5_context, const krb5_data *, krb5_data *);
893
894
krb5_error_code
895
krb5int_copy_data_contents_add0(krb5_context, const krb5_data *, krb5_data *);
896
897
void KRB5_CALLCONV
898
krb5_free_sam_challenge_2(krb5_context, krb5_sam_challenge_2 *);
899
900
void KRB5_CALLCONV
901
krb5_free_sam_challenge_2_body(krb5_context, krb5_sam_challenge_2_body *);
902
903
void KRB5_CALLCONV
904
krb5_free_sam_response_2(krb5_context, krb5_sam_response_2 *);
905
906
void KRB5_CALLCONV
907
krb5_free_enc_sam_response_enc_2(krb5_context, krb5_enc_sam_response_enc_2 *);
908
909
void KRB5_CALLCONV
910
krb5_free_sam_challenge_2_contents(krb5_context, krb5_sam_challenge_2 *);
911
912
void KRB5_CALLCONV
913
krb5_free_sam_challenge_2_body_contents(krb5_context,
914
                                        krb5_sam_challenge_2_body *);
915
916
void KRB5_CALLCONV
917
krb5_free_sam_response_2_contents(krb5_context, krb5_sam_response_2 *);
918
919
void KRB5_CALLCONV
920
krb5_free_enc_sam_response_enc_2_contents(krb5_context,
921
                                          krb5_enc_sam_response_enc_2 * );
922
923
void KRB5_CALLCONV
924
krb5_free_pa_enc_ts(krb5_context, krb5_pa_enc_ts *);
925
926
void KRB5_CALLCONV
927
krb5_free_pa_for_user(krb5_context, krb5_pa_for_user *);
928
929
void KRB5_CALLCONV
930
krb5_free_s4u_userid_contents(krb5_context, krb5_s4u_userid *);
931
932
void KRB5_CALLCONV
933
krb5_free_pa_s4u_x509_user(krb5_context, krb5_pa_s4u_x509_user *);
934
935
void KRB5_CALLCONV
936
krb5_free_pa_pac_req(krb5_context, krb5_pa_pac_req * );
937
938
void KRB5_CALLCONV krb5_free_fast_armor(krb5_context, krb5_fast_armor *);
939
void KRB5_CALLCONV krb5_free_fast_armored_req(krb5_context,
940
                                              krb5_fast_armored_req *);
941
void KRB5_CALLCONV krb5_free_fast_req(krb5_context, krb5_fast_req *);
942
void KRB5_CALLCONV krb5_free_fast_finished(krb5_context, krb5_fast_finished *);
943
void KRB5_CALLCONV krb5_free_fast_response(krb5_context, krb5_fast_response *);
944
void KRB5_CALLCONV krb5_free_ad_kdcissued(krb5_context, krb5_ad_kdcissued *);
945
void KRB5_CALLCONV krb5_free_iakerb_header(krb5_context, krb5_iakerb_header *);
946
void KRB5_CALLCONV krb5_free_iakerb_finished(krb5_context,
947
                                             krb5_iakerb_finished *);
948
void k5_free_algorithm_identifier(krb5_context context,
949
                                  krb5_algorithm_identifier *val);
950
void k5_free_otp_tokeninfo(krb5_context context, krb5_otp_tokeninfo *val);
951
void k5_free_pa_otp_challenge(krb5_context context,
952
                              krb5_pa_otp_challenge *val);
953
void k5_free_pa_otp_req(krb5_context context, krb5_pa_otp_req *val);
954
void k5_free_kkdcp_message(krb5_context context, krb5_kkdcp_message *val);
955
void k5_free_cammac(krb5_context context, krb5_cammac *val);
956
void k5_free_secure_cookie(krb5_context context, krb5_secure_cookie *val);
957
958
krb5_error_code
959
k5_unwrap_cammac_svc(krb5_context context, const krb5_authdata *ad,
960
                     const krb5_keyblock *key, krb5_authdata ***adata_out);
961
krb5_error_code
962
k5_authind_decode(const krb5_authdata *ad, krb5_data ***indicators);
963
964
/* #include "krb5/wordsize.h" -- comes in through base-defs.h. */
965
#include "com_err.h"
966
#include "k5-plugin.h"
967
968
#include <krb5/authdata_plugin.h>
969
970
struct _krb5_authdata_context {
971
    krb5_magic magic;
972
    int n_modules;
973
    struct _krb5_authdata_context_module {
974
        krb5_authdatatype ad_type;
975
        void *plugin_context;
976
        authdata_client_plugin_fini_proc client_fini;
977
        krb5_flags flags;
978
        krb5plugin_authdata_client_ftable_v0 *ftable;
979
        authdata_client_request_init_proc client_req_init;
980
        authdata_client_request_fini_proc client_req_fini;
981
        const char *name;
982
        void *request_context;
983
        void **request_context_pp;
984
    } *modules;
985
    struct plugin_dir_handle plugins;
986
};
987
988
typedef struct _krb5_authdata_context *krb5_authdata_context;
989
990
void
991
k5_free_data_ptr_list(krb5_data **list);
992
993
void
994
k5_zapfree_pa_data(krb5_pa_data **val);
995
996
void KRB5_CALLCONV
997
krb5int_free_data_list(krb5_context context, krb5_data *data);
998
999
krb5_error_code KRB5_CALLCONV
1000
krb5_authdata_context_init(krb5_context kcontext,
1001
                           krb5_authdata_context *pcontext);
1002
1003
void KRB5_CALLCONV
1004
krb5_authdata_context_free(krb5_context kcontext,
1005
                           krb5_authdata_context context);
1006
1007
krb5_error_code KRB5_CALLCONV
1008
krb5_authdata_export_authdata(krb5_context kcontext,
1009
                              krb5_authdata_context context, krb5_flags usage,
1010
                              krb5_authdata ***pauthdata);
1011
1012
krb5_error_code KRB5_CALLCONV
1013
krb5_authdata_get_attribute_types(krb5_context kcontext,
1014
                                  krb5_authdata_context context,
1015
                                  krb5_data **attrs);
1016
1017
krb5_error_code KRB5_CALLCONV
1018
krb5_authdata_get_attribute(krb5_context kcontext,
1019
                            krb5_authdata_context context,
1020
                            const krb5_data *attribute,
1021
                            krb5_boolean *authenticated,
1022
                            krb5_boolean *complete, krb5_data *value,
1023
                            krb5_data *display_value, int *more);
1024
1025
krb5_error_code KRB5_CALLCONV
1026
krb5_authdata_set_attribute(krb5_context kcontext,
1027
                            krb5_authdata_context context,
1028
                            krb5_boolean complete, const krb5_data *attribute,
1029
                            const krb5_data *value);
1030
1031
krb5_error_code KRB5_CALLCONV
1032
krb5_authdata_delete_attribute(krb5_context kcontext,
1033
                               krb5_authdata_context context,
1034
                               const krb5_data *attribute);
1035
1036
krb5_error_code KRB5_CALLCONV
1037
krb5_authdata_import_attributes(krb5_context kcontext,
1038
                                krb5_authdata_context context,
1039
                                krb5_flags usage, const krb5_data *attributes);
1040
1041
krb5_error_code KRB5_CALLCONV
1042
krb5_authdata_export_attributes(krb5_context kcontext,
1043
                                krb5_authdata_context context,
1044
                                krb5_flags usage, krb5_data **pattributes);
1045
1046
krb5_error_code KRB5_CALLCONV
1047
krb5_authdata_export_internal(krb5_context kcontext,
1048
                              krb5_authdata_context context,
1049
                              krb5_boolean restrict_authenticated,
1050
                              const char *module, void **ptr);
1051
1052
krb5_error_code KRB5_CALLCONV
1053
krb5_authdata_context_copy(krb5_context kcontext, krb5_authdata_context src,
1054
                           krb5_authdata_context *dst);
1055
1056
krb5_error_code KRB5_CALLCONV
1057
krb5_authdata_free_internal(krb5_context kcontext,
1058
                            krb5_authdata_context context, const char *module,
1059
                            void *ptr);
1060
1061
/*** Plugin framework ***/
1062
1063
/*
1064
 * This framework can be used to create pluggable interfaces.  Not all existing
1065
 * pluggable interface use this framework, but new ones should.  A new
1066
 * pluggable interface entails:
1067
 *
1068
 * - An interface ID definition in the list of #defines below.
1069
 *
1070
 * - A name in the interface_names array in lib/krb5/krb/plugins.c.
1071
 *
1072
 * - An installed public header file in include/krb5.  The public header should
1073
 *   include <krb5/plugin.h> and should declare a vtable structure for each
1074
 *   supported major version of the interface.
1075
 *
1076
 * - A consumer API implementation, located within the code unit which makes
1077
 *   use of the pluggable interface.  The consumer API should consist of:
1078
 *
1079
 *   . An interface-specific handle type which contains a vtable structure for
1080
 *     the module (or a union of several such structures, if there are multiple
1081
 *     supported major versions) and, optionally, resource data bound to the
1082
 *     handle.
1083
 *
1084
 *   . An interface-specific loader function which creates a handle or list of
1085
 *     handles.  A list of handles would be created if the interface is a
1086
 *     one-to-many interface where the consumer wants to consult all available
1087
 *     modules; a single handle would be created for an interface where the
1088
 *     consumer wants to consult a specific module.  The loader function should
1089
 *     use k5_plugin_load or k5_plugin_load_all to produce one or a list of
1090
 *     vtable initializer functions, and should use those functions to fill in
1091
 *     the vtable structure for the module (if necessary, trying each supported
1092
 *     major version starting from the most recent).  The loader function can
1093
 *     also bind resource data into the handle based on caller arguments, if
1094
 *     appropriate.
1095
 *
1096
 *   . For each plugin method, a wrapper function which accepts a krb5_context,
1097
 *     a plugin handle, and the method arguments.  Wrapper functions should
1098
 *     invoke the method function contained in the handle's vtable.
1099
 *
1100
 * - Possibly, built-in implementations of the interface, also located within
1101
 *   the code unit which makes use of the interface.  Built-in implementations
1102
 *   must be registered with k5_plugin_register before the first call to
1103
 *   k5_plugin_load or k5_plugin_load_all.
1104
 *
1105
 * A pluggable interface should have one or more currently supported major
1106
 * versions, starting at 1.  Each major version should have a current minor
1107
 * version, also starting at 1.  If new methods are added to a vtable, the
1108
 * minor version should be incremented and the vtable structure should document
1109
 * where each minor vtable version ends.  If method signatures for a vtable are
1110
 * changed, the major version should be incremented.
1111
 *
1112
 * Plugin module implementations (either built-in or dynamically loaded) should
1113
 * define a function named <interfacename>_<modulename>_initvt, matching the
1114
 * signature of krb5_plugin_initvt_fn as declared in include/krb5/plugin.h.
1115
 * The initvt function should check the given maj_ver argument against its own
1116
 * supported major versions, cast the vtable pointer to the appropriate
1117
 * interface-specific vtable type, and fill in the vtable methods, stopping as
1118
 * appropriate for the given min_ver.  Memory for the vtable structure is
1119
 * allocated by the caller, not by the module.
1120
 *
1121
 * Dynamic plugin modules are registered with the framework through the
1122
 * [plugins] section of the profile, as described in the admin documentation
1123
 * and krb5.conf man page.
1124
 */
1125
1126
struct plugin_mapping;
1127
1128
/* Holds krb5_context information about each pluggable interface. */
1129
struct plugin_interface {
1130
    struct plugin_mapping **modules;
1131
    krb5_boolean configured;
1132
};
1133
1134
/* A list of plugin interface IDs.  Make sure to increment
1135
 * PLUGIN_NUM_INTERFACES when a new interface is added, and add an entry to the
1136
 * interface_names table in lib/krb5/krb/plugin.c. */
1137
#define PLUGIN_INTERFACE_PWQUAL      0
1138
#define PLUGIN_INTERFACE_KADM5_HOOK  1
1139
#define PLUGIN_INTERFACE_CLPREAUTH   2
1140
#define PLUGIN_INTERFACE_KDCPREAUTH  3
1141
#define PLUGIN_INTERFACE_CCSELECT    4
1142
#define PLUGIN_INTERFACE_LOCALAUTH   5
1143
#define PLUGIN_INTERFACE_HOSTREALM   6
1144
#define PLUGIN_INTERFACE_AUDIT       7
1145
#define PLUGIN_INTERFACE_TLS         8
1146
#define PLUGIN_INTERFACE_KDCAUTHDATA 9
1147
#define PLUGIN_INTERFACE_CERTAUTH    10
1148
#define PLUGIN_INTERFACE_KADM5_AUTH  11
1149
#define PLUGIN_INTERFACE_KDCPOLICY   12
1150
#define PLUGIN_NUM_INTERFACES        13
1151
1152
/* Retrieve the plugin module of type interface_id and name modname,
1153
 * storing the result into module. */
1154
krb5_error_code
1155
k5_plugin_load(krb5_context context, int interface_id, const char *modname,
1156
               krb5_plugin_initvt_fn *module);
1157
1158
/* Retrieve all plugin modules of type interface_id, storing the result
1159
 * into modules.  Free the result with k5_plugin_free_handles. */
1160
krb5_error_code
1161
k5_plugin_load_all(krb5_context context, int interface_id,
1162
                   krb5_plugin_initvt_fn **modules);
1163
1164
/* Release a module list allocated by k5_plugin_load_all. */
1165
void
1166
k5_plugin_free_modules(krb5_context context, krb5_plugin_initvt_fn *modules);
1167
1168
/* Register a plugin module of type interface_id and name modname. */
1169
krb5_error_code
1170
k5_plugin_register(krb5_context context, int interface_id, const char *modname,
1171
                   krb5_plugin_initvt_fn module);
1172
1173
/*
1174
 * Register a plugin module which is part of the krb5 tree but is built as a
1175
 * dynamic plugin.  Look for the module in modsubdir relative to the
1176
 * context->base_plugin_dir.
1177
 */
1178
krb5_error_code
1179
k5_plugin_register_dyn(krb5_context context, int interface_id,
1180
                       const char *modname, const char *modsubdir);
1181
1182
/* Destroy the module state within context; used by krb5_free_context. */
1183
void
1184
k5_plugin_free_context(krb5_context context);
1185
1186
enum dns_canonhost {
1187
    CANONHOST_FALSE = 0,
1188
    CANONHOST_TRUE = 1,
1189
    CANONHOST_FALLBACK = 2
1190
};
1191
1192
struct _kdb5_dal_handle;        /* private, in kdb5.h */
1193
typedef struct _kdb5_dal_handle kdb5_dal_handle;
1194
struct _kdb_log_context;
1195
typedef struct krb5_preauth_context_st *krb5_preauth_context;
1196
struct ccselect_module_handle;
1197
struct localauth_module_handle;
1198
struct hostrealm_module_handle;
1199
struct k5_tls_vtable_st;
1200
struct _krb5_context {
1201
    krb5_magic      magic;
1202
    krb5_enctype    *tgs_etypes;
1203
    struct _krb5_os_context os_context;
1204
    char            *default_realm;
1205
    profile_t       profile;
1206
    kdb5_dal_handle *dal_handle;
1207
    /* allowable clock skew */
1208
    krb5_deltat     clockskew;
1209
    krb5_deltat     req_timeout;
1210
    krb5_flags      kdc_default_options;
1211
    krb5_flags      library_options;
1212
    krb5_boolean    profile_secure;
1213
    int             fcc_default_format;
1214
    krb5_prompt_type *prompt_types;
1215
    /* Message size above which we'll try TCP first in send-to-kdc
1216
       type code.  Aside from the 2**16 size limit, we put no
1217
       absolute limit on the UDP packet size.  */
1218
    int             udp_pref_limit;
1219
1220
    /* Use the config-file ktypes instead of app-specified?  */
1221
    krb5_boolean    use_conf_ktypes;
1222
1223
    /* locate_kdc module stuff */
1224
    struct plugin_dir_handle libkrb5_plugins;
1225
1226
    /* preauth module stuff */
1227
    krb5_preauth_context preauth_context;
1228
1229
    /* cache module stuff */
1230
    struct ccselect_module_handle **ccselect_handles;
1231
1232
    /* localauth module stuff */
1233
    struct localauth_module_handle **localauth_handles;
1234
1235
    /* hostrealm module stuff */
1236
    struct hostrealm_module_handle **hostrealm_handles;
1237
1238
    /* TLS module vtable (if loaded) */
1239
    struct k5_tls_vtable_st *tls;
1240
1241
    /* error detail info */
1242
    struct errinfo err;
1243
    char *err_fmt;
1244
1245
    /* For Sun iprop code; does this really have to be here?  */
1246
    struct _kdb_log_context *kdblog_context;
1247
1248
    krb5_boolean allow_weak_crypto;
1249
    krb5_boolean allow_des3;
1250
    krb5_boolean allow_rc4;
1251
    krb5_boolean ignore_acceptor_hostname;
1252
    krb5_boolean enforce_ok_as_delegate;
1253
    enum dns_canonhost dns_canonicalize_hostname;
1254
1255
    krb5_trace_callback trace_callback;
1256
    void *trace_callback_data;
1257
1258
    krb5_pre_send_fn kdc_send_hook;
1259
    void *kdc_send_hook_data;
1260
1261
    krb5_post_recv_fn kdc_recv_hook;
1262
    void *kdc_recv_hook_data;
1263
1264
    struct plugin_interface plugins[PLUGIN_NUM_INTERFACES];
1265
    char *plugin_base_dir;
1266
};
1267
1268
/* could be used in a table to find an etype and initialize a block */
1269
1270
1271
#define KRB5_LIBOPT_SYNC_KDCTIME        0x0001
1272
1273
/* internal message representations */
1274
1275
typedef struct _krb5_safe {
1276
    krb5_magic magic;
1277
    krb5_data user_data;                /* user data */
1278
    krb5_timestamp timestamp;           /* client time, optional */
1279
    krb5_int32 usec;                    /* microsecond portion of time,
1280
                                           optional */
1281
    krb5_ui_4 seq_number;               /* sequence #, optional */
1282
    krb5_address *s_address;    /* sender address */
1283
    krb5_address *r_address;    /* recipient address, optional */
1284
    krb5_checksum *checksum;    /* data integrity checksum */
1285
} krb5_safe;
1286
1287
typedef struct _krb5_priv {
1288
    krb5_magic magic;
1289
    krb5_enc_data enc_part;             /* encrypted part */
1290
} krb5_priv;
1291
1292
typedef struct _krb5_priv_enc_part {
1293
    krb5_magic magic;
1294
    krb5_data user_data;                /* user data */
1295
    krb5_timestamp timestamp;           /* client time, optional */
1296
    krb5_int32 usec;                    /* microsecond portion of time, opt. */
1297
    krb5_ui_4 seq_number;               /* sequence #, optional */
1298
    krb5_address *s_address;    /* sender address */
1299
    krb5_address *r_address;    /* recipient address, optional */
1300
} krb5_priv_enc_part;
1301
1302
void KRB5_CALLCONV krb5_free_safe(krb5_context, krb5_safe *);
1303
void KRB5_CALLCONV krb5_free_priv(krb5_context, krb5_priv *);
1304
void KRB5_CALLCONV krb5_free_priv_enc_part(krb5_context, krb5_priv_enc_part *);
1305
1306
/*
1307
 * Begin "asn1.h"
1308
 */
1309
#ifndef KRB5_ASN1__
1310
#define KRB5_ASN1__
1311
1312
/* ASN.1 encoding knowledge; KEEP IN SYNC WITH ASN.1 defs! */
1313
/* here we use some knowledge of ASN.1 encodings */
1314
/*
1315
  Ticket is APPLICATION 1.
1316
  Authenticator is APPLICATION 2.
1317
  AS_REQ is APPLICATION 10.
1318
  AS_REP is APPLICATION 11.
1319
  TGS_REQ is APPLICATION 12.
1320
  TGS_REP is APPLICATION 13.
1321
  AP_REQ is APPLICATION 14.
1322
  AP_REP is APPLICATION 15.
1323
  KRB_SAFE is APPLICATION 20.
1324
  KRB_PRIV is APPLICATION 21.
1325
  KRB_CRED is APPLICATION 22.
1326
  EncASRepPart is APPLICATION 25.
1327
  EncTGSRepPart is APPLICATION 26.
1328
  EncAPRepPart is APPLICATION 27.
1329
  EncKrbPrivPart is APPLICATION 28.
1330
  EncKrbCredPart is APPLICATION 29.
1331
  KRB_ERROR is APPLICATION 30.
1332
*/
1333
/* allow either constructed or primitive encoding, so check for bit 6
1334
   set or reset */
1335
#define krb5int_is_app_tag(dat,tag)                     \
1336
    ((dat != NULL) && (dat)->length &&                  \
1337
     ((((dat)->data[0] & ~0x20) == ((tag) | 0x40))))
1338
#define krb5_is_krb_ticket(dat)               krb5int_is_app_tag(dat, 1)
1339
#define krb5_is_krb_authenticator(dat)        krb5int_is_app_tag(dat, 2)
1340
#define krb5_is_as_req(dat)                   krb5int_is_app_tag(dat, 10)
1341
#define krb5_is_as_rep(dat)                   krb5int_is_app_tag(dat, 11)
1342
#define krb5_is_tgs_req(dat)                  krb5int_is_app_tag(dat, 12)
1343
#define krb5_is_tgs_rep(dat)                  krb5int_is_app_tag(dat, 13)
1344
#define krb5_is_ap_req(dat)                   krb5int_is_app_tag(dat, 14)
1345
#define krb5_is_ap_rep(dat)                   krb5int_is_app_tag(dat, 15)
1346
#define krb5_is_krb_safe(dat)                 krb5int_is_app_tag(dat, 20)
1347
#define krb5_is_krb_priv(dat)                 krb5int_is_app_tag(dat, 21)
1348
#define krb5_is_krb_cred(dat)                 krb5int_is_app_tag(dat, 22)
1349
#define krb5_is_krb_enc_as_rep_part(dat)      krb5int_is_app_tag(dat, 25)
1350
#define krb5_is_krb_enc_tgs_rep_part(dat)     krb5int_is_app_tag(dat, 26)
1351
#define krb5_is_krb_enc_ap_rep_part(dat)      krb5int_is_app_tag(dat, 27)
1352
#define krb5_is_krb_enc_krb_priv_part(dat)    krb5int_is_app_tag(dat, 28)
1353
#define krb5_is_krb_enc_krb_cred_part(dat)    krb5int_is_app_tag(dat, 29)
1354
#define krb5_is_krb_error(dat)                krb5int_is_app_tag(dat, 30)
1355
1356
/*************************************************************************
1357
 * Prototypes for krb5_encode.c
1358
 *************************************************************************/
1359
1360
/*
1361
  krb5_error_code encode_krb5_structure(const krb5_structure *rep,
1362
  krb5_data **code);
1363
  modifies  *code
1364
  effects   Returns the ASN.1 encoding of *rep in **code.
1365
  Returns ASN1_MISSING_FIELD if a required field is empty in *rep.
1366
  Returns ENOMEM if memory runs out.
1367
*/
1368
1369
krb5_error_code
1370
encode_krb5_authenticator(const krb5_authenticator *rep, krb5_data **code);
1371
1372
krb5_error_code
1373
encode_krb5_ticket(const krb5_ticket *rep, krb5_data **code);
1374
1375
krb5_error_code
1376
encode_krb5_enc_tkt_part(const krb5_enc_tkt_part *rep, krb5_data **code);
1377
1378
krb5_error_code
1379
encode_krb5_enc_kdc_rep_part(const krb5_enc_kdc_rep_part *rep,
1380
                             krb5_data **code);
1381
1382
/* yes, the translation is identical to that used for KDC__REP */
1383
krb5_error_code
1384
encode_krb5_as_rep(const krb5_kdc_rep *rep, krb5_data **code);
1385
1386
/* yes, the translation is identical to that used for KDC__REP */
1387
krb5_error_code
1388
encode_krb5_tgs_rep(const krb5_kdc_rep *rep, krb5_data **code);
1389
1390
krb5_error_code
1391
encode_krb5_ap_req(const krb5_ap_req *rep, krb5_data **code);
1392
1393
krb5_error_code
1394
encode_krb5_ap_rep(const krb5_ap_rep *rep, krb5_data **code);
1395
1396
krb5_error_code
1397
encode_krb5_ap_rep_enc_part(const krb5_ap_rep_enc_part *rep, krb5_data **code);
1398
1399
krb5_error_code
1400
encode_krb5_as_req(const krb5_kdc_req *rep, krb5_data **code);
1401
1402
krb5_error_code
1403
encode_krb5_tgs_req(const krb5_kdc_req *rep, krb5_data **code);
1404
1405
krb5_error_code
1406
encode_krb5_kdc_req_body(const krb5_kdc_req *rep, krb5_data **code);
1407
1408
krb5_error_code
1409
encode_krb5_safe(const krb5_safe *rep, krb5_data **code);
1410
1411
struct krb5_safe_with_body {
1412
    krb5_safe *safe;
1413
    krb5_data *body;
1414
};
1415
krb5_error_code
1416
encode_krb5_safe_with_body(const struct krb5_safe_with_body *rep,
1417
                           krb5_data **code);
1418
1419
krb5_error_code
1420
encode_krb5_priv(const krb5_priv *rep, krb5_data **code);
1421
1422
krb5_error_code
1423
encode_krb5_enc_priv_part(const krb5_priv_enc_part *rep, krb5_data **code);
1424
1425
krb5_error_code
1426
encode_krb5_cred(const krb5_cred *rep, krb5_data **code);
1427
krb5_error_code
1428
encode_krb5_checksum(const krb5_checksum *, krb5_data **);
1429
1430
krb5_error_code
1431
encode_krb5_enc_cred_part(const krb5_cred_enc_part *rep, krb5_data **code);
1432
1433
krb5_error_code
1434
encode_krb5_error(const krb5_error *rep, krb5_data **code);
1435
1436
krb5_error_code
1437
encode_krb5_authdata(krb5_authdata *const *rep, krb5_data **code);
1438
1439
krb5_error_code
1440
encode_krb5_padata_sequence(krb5_pa_data *const *rep, krb5_data **code);
1441
1442
krb5_error_code
1443
encode_krb5_typed_data(krb5_pa_data *const *rep, krb5_data **code);
1444
1445
krb5_error_code
1446
encode_krb5_etype_info(krb5_etype_info_entry *const *, krb5_data **code);
1447
1448
krb5_error_code
1449
encode_krb5_etype_info2(krb5_etype_info_entry *const *, krb5_data **code);
1450
1451
krb5_error_code
1452
encode_krb5_pa_enc_ts(const krb5_pa_enc_ts *, krb5_data **);
1453
1454
krb5_error_code
1455
encode_krb5_sam_challenge_2(const krb5_sam_challenge_2 * , krb5_data **);
1456
1457
krb5_error_code
1458
encode_krb5_sam_challenge_2_body(const krb5_sam_challenge_2_body *,
1459
                                 krb5_data **);
1460
1461
krb5_error_code
1462
encode_krb5_enc_sam_response_enc_2(const krb5_enc_sam_response_enc_2 *,
1463
                                   krb5_data **);
1464
1465
krb5_error_code
1466
encode_krb5_sam_response_2(const krb5_sam_response_2 * , krb5_data **);
1467
1468
struct krb5_setpw_req {
1469
    krb5_principal target;
1470
    krb5_data password;
1471
};
1472
krb5_error_code
1473
encode_krb5_setpw_req(const struct krb5_setpw_req *rep, krb5_data **code);
1474
1475
krb5_error_code
1476
encode_krb5_pa_for_user(const krb5_pa_for_user *, krb5_data **);
1477
1478
krb5_error_code
1479
encode_krb5_s4u_userid(const krb5_s4u_userid *, krb5_data **);
1480
1481
krb5_error_code
1482
encode_krb5_pa_s4u_x509_user(const krb5_pa_s4u_x509_user *, krb5_data **);
1483
1484
krb5_error_code
1485
encode_krb5_pa_pac_req(const krb5_pa_pac_req *, krb5_data **);
1486
1487
krb5_error_code
1488
encode_krb5_etype_list(const krb5_etype_list * , krb5_data **);
1489
1490
krb5_error_code
1491
encode_krb5_pa_fx_fast_request(const krb5_fast_armored_req *, krb5_data **);
1492
1493
krb5_error_code
1494
encode_krb5_fast_req(const krb5_fast_req *, krb5_data **);
1495
1496
krb5_error_code
1497
encode_krb5_pa_fx_fast_reply(const krb5_enc_data *, krb5_data **);
1498
1499
krb5_error_code
1500
encode_krb5_iakerb_header(const krb5_iakerb_header *, krb5_data **);
1501
1502
krb5_error_code
1503
encode_krb5_iakerb_finished(const krb5_iakerb_finished *, krb5_data **);
1504
1505
krb5_error_code
1506
encode_krb5_fast_response(const krb5_fast_response *, krb5_data **);
1507
1508
krb5_error_code
1509
encode_krb5_ad_kdcissued(const krb5_ad_kdcissued *, krb5_data **);
1510
1511
krb5_error_code
1512
encode_krb5_otp_tokeninfo(const krb5_otp_tokeninfo *, krb5_data **);
1513
1514
krb5_error_code
1515
encode_krb5_pa_otp_challenge(const krb5_pa_otp_challenge *, krb5_data **);
1516
1517
krb5_error_code
1518
encode_krb5_pa_otp_req(const krb5_pa_otp_req *, krb5_data **);
1519
1520
krb5_error_code
1521
encode_krb5_pa_otp_enc_req(const krb5_data *, krb5_data **);
1522
1523
krb5_error_code
1524
encode_krb5_kkdcp_message(const krb5_kkdcp_message *, krb5_data **);
1525
1526
krb5_error_code
1527
encode_krb5_cammac(const krb5_cammac *, krb5_data **);
1528
1529
krb5_error_code
1530
encode_utf8_strings(krb5_data *const *ut8fstrings, krb5_data **);
1531
1532
krb5_error_code
1533
encode_krb5_secure_cookie(const krb5_secure_cookie *, krb5_data **);
1534
1535
krb5_error_code
1536
encode_krb5_pa_pac_options(const krb5_pa_pac_options *, krb5_data **);
1537
1538
/*************************************************************************
1539
 * End of prototypes for krb5_encode.c
1540
 *************************************************************************/
1541
1542
krb5_error_code
1543
decode_krb5_sam_challenge_2(const krb5_data *, krb5_sam_challenge_2 **);
1544
1545
krb5_error_code
1546
decode_krb5_sam_challenge_2_body(const krb5_data *,
1547
                                 krb5_sam_challenge_2_body **);
1548
1549
krb5_error_code
1550
decode_krb5_enc_sam_response_enc_2(const krb5_data *,
1551
                                   krb5_enc_sam_response_enc_2 **);
1552
1553
krb5_error_code
1554
decode_krb5_sam_response_2(const krb5_data *, krb5_sam_response_2 **);
1555
1556
1557
/*************************************************************************
1558
 * Prototypes for krb5_decode.c
1559
 *************************************************************************/
1560
/*
1561
  krb5_error_code decode_krb5_structure(const krb5_data *code,
1562
  krb5_structure **rep);
1563
1564
  requires  Expects **rep to not have been allocated;
1565
  a new *rep is allocated regardless of the old value.
1566
  effects   Decodes *code into **rep.
1567
  Returns ENOMEM if memory is exhausted.
1568
  Returns asn1 and krb5 errors.
1569
*/
1570
1571
krb5_error_code
1572
decode_krb5_authenticator(const krb5_data *code, krb5_authenticator **rep);
1573
1574
krb5_error_code
1575
decode_krb5_ticket(const krb5_data *code, krb5_ticket **rep);
1576
1577
krb5_error_code
1578
decode_krb5_encryption_key(const krb5_data *output, krb5_keyblock **rep);
1579
1580
krb5_error_code
1581
decode_krb5_enc_tkt_part(const krb5_data *output, krb5_enc_tkt_part **rep);
1582
1583
krb5_error_code
1584
decode_krb5_enc_kdc_rep_part(const krb5_data *output,
1585
                             krb5_enc_kdc_rep_part **rep);
1586
1587
krb5_error_code
1588
decode_krb5_as_rep(const krb5_data *output, krb5_kdc_rep **rep);
1589
1590
krb5_error_code
1591
decode_krb5_tgs_rep(const krb5_data *output, krb5_kdc_rep **rep);
1592
1593
krb5_error_code
1594
decode_krb5_ap_req(const krb5_data *output, krb5_ap_req **rep);
1595
1596
krb5_error_code
1597
decode_krb5_ap_rep(const krb5_data *output, krb5_ap_rep **rep);
1598
1599
krb5_error_code
1600
decode_krb5_ap_rep_enc_part(const krb5_data *output,
1601
                            krb5_ap_rep_enc_part **rep);
1602
1603
krb5_error_code
1604
decode_krb5_as_req(const krb5_data *output, krb5_kdc_req **rep);
1605
1606
krb5_error_code
1607
decode_krb5_tgs_req(const krb5_data *output, krb5_kdc_req **rep);
1608
1609
krb5_error_code
1610
decode_krb5_kdc_req_body(const krb5_data *output, krb5_kdc_req **rep);
1611
1612
krb5_error_code
1613
decode_krb5_safe(const krb5_data *output, krb5_safe **rep);
1614
1615
krb5_error_code
1616
decode_krb5_safe_with_body(const krb5_data *output, krb5_safe **rep,
1617
                           krb5_data **body);
1618
1619
krb5_error_code
1620
decode_krb5_priv(const krb5_data *output, krb5_priv **rep);
1621
1622
krb5_error_code
1623
decode_krb5_enc_priv_part(const krb5_data *output, krb5_priv_enc_part **rep);
1624
krb5_error_code
1625
decode_krb5_checksum(const krb5_data *, krb5_checksum **);
1626
1627
krb5_error_code
1628
decode_krb5_cred(const krb5_data *output, krb5_cred **rep);
1629
1630
krb5_error_code
1631
decode_krb5_enc_cred_part(const krb5_data *output, krb5_cred_enc_part **rep);
1632
1633
krb5_error_code
1634
decode_krb5_error(const krb5_data *output, krb5_error **rep);
1635
1636
krb5_error_code
1637
decode_krb5_authdata(const krb5_data *output, krb5_authdata ***rep);
1638
1639
krb5_error_code
1640
decode_krb5_padata_sequence(const krb5_data *output, krb5_pa_data ***rep);
1641
1642
krb5_error_code
1643
decode_krb5_typed_data(const krb5_data *, krb5_pa_data ***);
1644
1645
krb5_error_code
1646
decode_krb5_etype_info(const krb5_data *output, krb5_etype_info_entry ***rep);
1647
1648
krb5_error_code
1649
decode_krb5_etype_info2(const krb5_data *output, krb5_etype_info_entry ***rep);
1650
1651
krb5_error_code
1652
decode_krb5_enc_data(const krb5_data *output, krb5_enc_data **rep);
1653
1654
krb5_error_code
1655
decode_krb5_pa_enc_ts(const krb5_data *output, krb5_pa_enc_ts **rep);
1656
1657
krb5_error_code
1658
decode_krb5_setpw_req(const krb5_data *, krb5_data **, krb5_principal *);
1659
1660
krb5_error_code
1661
decode_krb5_pa_for_user(const krb5_data *, krb5_pa_for_user **);
1662
1663
krb5_error_code
1664
decode_krb5_pa_s4u_x509_user(const krb5_data *, krb5_pa_s4u_x509_user **);
1665
1666
krb5_error_code
1667
decode_krb5_pa_pac_req(const krb5_data *, krb5_pa_pac_req **);
1668
1669
krb5_error_code
1670
decode_krb5_etype_list(const krb5_data *, krb5_etype_list **);
1671
1672
krb5_error_code
1673
decode_krb5_pa_fx_fast_request(const krb5_data *, krb5_fast_armored_req **);
1674
1675
krb5_error_code
1676
decode_krb5_fast_req(const krb5_data *, krb5_fast_req **);
1677
1678
krb5_error_code
1679
decode_krb5_pa_fx_fast_reply(const krb5_data *, krb5_enc_data **);
1680
1681
krb5_error_code
1682
decode_krb5_fast_response(const krb5_data *, krb5_fast_response **);
1683
1684
krb5_error_code
1685
decode_krb5_ad_kdcissued(const krb5_data *, krb5_ad_kdcissued **);
1686
1687
krb5_error_code
1688
decode_krb5_iakerb_header(const krb5_data *, krb5_iakerb_header **);
1689
1690
krb5_error_code
1691
decode_krb5_iakerb_finished(const krb5_data *, krb5_iakerb_finished **);
1692
1693
krb5_error_code
1694
decode_krb5_otp_tokeninfo(const krb5_data *, krb5_otp_tokeninfo **);
1695
1696
krb5_error_code
1697
decode_krb5_pa_otp_challenge(const krb5_data *, krb5_pa_otp_challenge **);
1698
1699
krb5_error_code
1700
decode_krb5_pa_otp_req(const krb5_data *, krb5_pa_otp_req **);
1701
1702
krb5_error_code
1703
decode_krb5_pa_otp_enc_req(const krb5_data *, krb5_data **);
1704
1705
krb5_error_code
1706
decode_krb5_kkdcp_message(const krb5_data *, krb5_kkdcp_message **);
1707
1708
krb5_error_code
1709
decode_krb5_cammac(const krb5_data *, krb5_cammac **);
1710
1711
krb5_error_code
1712
decode_utf8_strings(const krb5_data *, krb5_data ***);
1713
1714
krb5_error_code
1715
decode_krb5_secure_cookie(const krb5_data *, krb5_secure_cookie **);
1716
1717
krb5_error_code
1718
decode_krb5_pa_pac_options(const krb5_data *, krb5_pa_pac_options **);
1719
1720
struct _krb5_key_data;          /* kdb.h */
1721
1722
struct ldap_seqof_key_data {
1723
    krb5_int32 mkvno;           /* Master key version number */
1724
    krb5_ui_2 kvno;             /* kvno of key_data elements (all the same) */
1725
    struct _krb5_key_data *key_data;
1726
    krb5_int16 n_key_data;
1727
};
1728
typedef struct ldap_seqof_key_data ldap_seqof_key_data;
1729
1730
krb5_error_code
1731
krb5int_ldap_encode_sequence_of_keys(const ldap_seqof_key_data *val,
1732
                                     krb5_data **code);
1733
1734
krb5_error_code
1735
krb5int_ldap_decode_sequence_of_keys(const krb5_data *in,
1736
                                     ldap_seqof_key_data **rep);
1737
1738
/*************************************************************************
1739
 * End of prototypes for krb5_decode.c
1740
 *************************************************************************/
1741
1742
#endif /* KRB5_ASN1__ */
1743
/*
1744
 * End "asn1.h"
1745
 */
1746
1747
1748
/*
1749
 * Internal krb5 library routines
1750
 */
1751
krb5_error_code
1752
krb5_encrypt_tkt_part(krb5_context, const krb5_keyblock *, krb5_ticket *);
1753
1754
krb5_error_code
1755
krb5_encode_kdc_rep(krb5_context, krb5_msgtype, const krb5_enc_kdc_rep_part *,
1756
                    int using_subkey, const krb5_keyblock *, krb5_kdc_rep *,
1757
                    krb5_data ** );
1758
1759
/* Return true if s is non-empty and composed solely of digits. */
1760
krb5_boolean
1761
k5_is_string_numeric(const char *s);
1762
1763
krb5_error_code
1764
k5_parse_host_string(const char *address, int default_port, char **host_out,
1765
                     int *port_out);
1766
1767
krb5_error_code
1768
k5_size_authdata_context(krb5_context kcontext, krb5_authdata_context context,
1769
                         size_t *sizep);
1770
1771
krb5_error_code
1772
k5_externalize_authdata_context(krb5_context kcontext,
1773
                                krb5_authdata_context context,
1774
                                krb5_octet **buffer, size_t *lenremain);
1775
1776
krb5_error_code
1777
k5_internalize_authdata_context(krb5_context kcontext,
1778
                                krb5_authdata_context *ptr,
1779
                                krb5_octet **buffer, size_t *lenremain);
1780
1781
krb5_error_code
1782
k5_size_auth_context(krb5_auth_context auth_context, size_t *sizep);
1783
1784
krb5_error_code
1785
k5_externalize_auth_context(krb5_auth_context auth_context,
1786
                            krb5_octet **buffer, size_t *lenremain);
1787
krb5_error_code
1788
k5_internalize_auth_context(krb5_auth_context *argp,
1789
                            krb5_octet **buffer, size_t *lenremain);
1790
1791
krb5_error_code
1792
k5_size_authdata(krb5_authdata *authdata, size_t *sizep);
1793
1794
krb5_error_code
1795
k5_externalize_authdata(krb5_authdata *authdata,
1796
                        krb5_octet **buffer, size_t *lenremain);
1797
1798
krb5_error_code
1799
k5_internalize_authdata(krb5_authdata **authdata,
1800
                        krb5_octet **buffer, size_t *lenremain);
1801
1802
krb5_error_code
1803
k5_size_address(krb5_address *address, size_t *sizep);
1804
1805
krb5_error_code
1806
k5_externalize_address(krb5_address *address,
1807
                       krb5_octet **buffer, size_t *lenremain);
1808
1809
krb5_error_code
1810
k5_internalize_address(krb5_address **argp,
1811
                       krb5_octet **buffer, size_t *lenremain);
1812
1813
krb5_error_code
1814
k5_size_authenticator(krb5_authenticator *authenticator, size_t *sizep);
1815
1816
krb5_error_code
1817
k5_externalize_authenticator(krb5_authenticator *authenticator,
1818
                             krb5_octet **buffer, size_t *lenremain);
1819
1820
krb5_error_code
1821
k5_internalize_authenticator(krb5_authenticator **argp,
1822
                             krb5_octet **buffer, size_t *lenremain);
1823
1824
krb5_error_code
1825
k5_size_checksum(krb5_checksum *checksum, size_t *sizep);
1826
1827
krb5_error_code
1828
k5_externalize_checksum(krb5_checksum *checksum,
1829
                        krb5_octet **buffer, size_t *lenremain);
1830
1831
krb5_error_code
1832
k5_internalize_checksum(krb5_checksum **argp,
1833
                        krb5_octet **buffer, size_t *lenremain);
1834
1835
krb5_error_code
1836
k5_size_context(krb5_context context, size_t *sizep);
1837
1838
krb5_error_code
1839
k5_externalize_context(krb5_context context,
1840
                       krb5_octet **buffer, size_t *lenremain);
1841
1842
krb5_error_code
1843
k5_internalize_context(krb5_context *argp,
1844
                       krb5_octet **buffer, size_t *lenremain);
1845
1846
krb5_error_code
1847
k5_size_keyblock(krb5_keyblock *keyblock, size_t *sizep);
1848
1849
krb5_error_code
1850
k5_externalize_keyblock(krb5_keyblock *keyblock,
1851
                        krb5_octet **buffer, size_t *lenremain);
1852
1853
krb5_error_code
1854
k5_internalize_keyblock(krb5_keyblock **argp,
1855
                        krb5_octet **buffer, size_t *lenremain);
1856
1857
krb5_error_code
1858
k5_size_principal(krb5_principal principal, size_t *sizep);
1859
1860
krb5_error_code
1861
k5_externalize_principal(krb5_principal principal,
1862
                         krb5_octet **buffer, size_t *lenremain);
1863
1864
krb5_error_code
1865
k5_internalize_principal(krb5_principal *argp,
1866
                         krb5_octet **buffer, size_t *lenremain);
1867
1868
/*
1869
 * Initialization routines.
1870
 */
1871
1872
/* [De]serialize 4-byte integer */
1873
krb5_error_code KRB5_CALLCONV
1874
krb5_ser_pack_int32(krb5_int32, krb5_octet **, size_t *);
1875
1876
krb5_error_code KRB5_CALLCONV
1877
krb5_ser_unpack_int32(krb5_int32 *, krb5_octet **, size_t *);
1878
1879
/* [De]serialize 8-byte integer */
1880
krb5_error_code KRB5_CALLCONV
1881
krb5_ser_pack_int64(int64_t, krb5_octet **, size_t *);
1882
1883
krb5_error_code KRB5_CALLCONV
1884
krb5_ser_unpack_int64(int64_t *, krb5_octet **, size_t *);
1885
1886
krb5_error_code
1887
k5_ser_unpack_len(size_t *len_out, krb5_octet **bufp, size_t *remainp);
1888
1889
/* [De]serialize byte string */
1890
krb5_error_code KRB5_CALLCONV
1891
krb5_ser_pack_bytes(krb5_octet *, size_t, krb5_octet **, size_t *);
1892
1893
krb5_error_code KRB5_CALLCONV
1894
krb5_ser_unpack_bytes(krb5_octet *, size_t, krb5_octet **, size_t *);
1895
1896
krb5_error_code KRB5_CALLCONV
1897
krb5int_cc_default(krb5_context, krb5_ccache *);
1898
1899
krb5_error_code
1900
k5_cc_store_primary_cred(krb5_context, krb5_ccache, krb5_creds *);
1901
1902
/* Fill in the buffer with random alphanumeric data. */
1903
krb5_error_code
1904
krb5int_random_string(krb5_context, char *string, unsigned int length);
1905
1906
/* value to use when requesting a keytab entry and KVNO doesn't matter */
1907
#define IGNORE_VNO 0
1908
/* value to use when requesting a keytab entry and enctype doesn't matter */
1909
#define IGNORE_ENCTYPE 0
1910
1911
/* To keep happy libraries which are (for now) accessing internal stuff */
1912
1913
/* Make sure to increment by one when changing the struct */
1914
#define KRB5INT_ACCESS_STRUCT_VERSION 23
1915
1916
typedef struct _krb5int_access {
1917
    krb5_error_code (*auth_con_get_subkey_enctype)(krb5_context,
1918
                                                   krb5_auth_context,
1919
                                                   krb5_enctype *);
1920
1921
    krb5_error_code (*mandatory_cksumtype)(krb5_context, krb5_enctype,
1922
                                           krb5_cksumtype *);
1923
    krb5_error_code (KRB5_CALLCONV *ser_pack_int64)(int64_t, krb5_octet **,
1924
                                                    size_t *);
1925
    krb5_error_code (KRB5_CALLCONV *ser_unpack_int64)(int64_t *, krb5_octet **,
1926
                                                      size_t *);
1927
1928
    /* Used for KDB LDAP back end.  */
1929
    krb5_error_code
1930
    (*asn1_ldap_encode_sequence_of_keys)(const ldap_seqof_key_data *val,
1931
                                         krb5_data **code);
1932
1933
    krb5_error_code
1934
    (*asn1_ldap_decode_sequence_of_keys)(const krb5_data *in,
1935
                                         ldap_seqof_key_data **);
1936
1937
    /*
1938
     * pkinit asn.1 encode/decode functions
1939
     */
1940
    krb5_error_code
1941
    (*encode_krb5_auth_pack)(const krb5_auth_pack *rep, krb5_data **code);
1942
1943
    krb5_error_code
1944
    (*encode_krb5_kdc_dh_key_info)(const krb5_kdc_dh_key_info *rep,
1945
                                   krb5_data **code);
1946
1947
    krb5_error_code
1948
    (*encode_krb5_pa_pk_as_rep)(const krb5_pa_pk_as_rep *rep,
1949
                                krb5_data **code);
1950
1951
    krb5_error_code
1952
    (*encode_krb5_pa_pk_as_req)(const krb5_pa_pk_as_req *rep,
1953
                                krb5_data **code);
1954
1955
    krb5_error_code
1956
    (*encode_krb5_reply_key_pack)(const krb5_reply_key_pack *,
1957
                                  krb5_data **code);
1958
1959
    krb5_error_code
1960
    (*encode_krb5_td_dh_parameters)(krb5_algorithm_identifier *const *,
1961
                                    krb5_data **code);
1962
1963
    krb5_error_code
1964
    (*encode_krb5_td_trusted_certifiers)(krb5_external_principal_identifier *
1965
                                         const *, krb5_data **code);
1966
1967
    krb5_error_code
1968
    (*decode_krb5_auth_pack)(const krb5_data *, krb5_auth_pack **);
1969
1970
    krb5_error_code
1971
    (*decode_krb5_pa_pk_as_req)(const krb5_data *, krb5_pa_pk_as_req **);
1972
1973
    krb5_error_code
1974
    (*decode_krb5_pa_pk_as_rep)(const krb5_data *, krb5_pa_pk_as_rep **);
1975
1976
    krb5_error_code
1977
    (*decode_krb5_kdc_dh_key_info)(const krb5_data *, krb5_kdc_dh_key_info **);
1978
1979
    krb5_error_code
1980
    (*decode_krb5_principal_name)(const krb5_data *, krb5_principal_data **);
1981
1982
    krb5_error_code
1983
    (*decode_krb5_reply_key_pack)(const krb5_data *, krb5_reply_key_pack **);
1984
1985
    krb5_error_code
1986
    (*decode_krb5_td_dh_parameters)(const krb5_data *,
1987
                                    krb5_algorithm_identifier ***);
1988
1989
    krb5_error_code
1990
    (*decode_krb5_td_trusted_certifiers)(const krb5_data *,
1991
                                         krb5_external_principal_identifier
1992
                                         ***);
1993
1994
    krb5_error_code
1995
    (*encode_krb5_kdc_req_body)(const krb5_kdc_req *rep, krb5_data **code);
1996
1997
    void
1998
    (KRB5_CALLCONV *free_kdc_req)(krb5_context, krb5_kdc_req * );
1999
    void
2000
    (*set_prompt_types)(krb5_context, krb5_prompt_type *);
2001
} krb5int_access;
2002
2003
#define KRB5INT_ACCESS_VERSION                                          \
2004
    (((krb5_int32)((sizeof(krb5int_access) & 0xFFFF) |                  \
2005
                   (KRB5INT_ACCESS_STRUCT_VERSION << 16))) & 0xFFFFFFFF)
2006
2007
krb5_error_code KRB5_CALLCONV
2008
krb5int_accessor(krb5int_access*, krb5_int32);
2009
2010
krb5_error_code KRB5_CALLCONV
2011
krb5int_cc_user_set_default_name(krb5_context context, const char *name);
2012
2013
krb5_error_code k5_rc_default(krb5_context context, krb5_rcache *rc_out);
2014
krb5_error_code k5_rc_resolve(krb5_context context, const char *name,
2015
                              krb5_rcache *rc_out);
2016
void k5_rc_close(krb5_context context, krb5_rcache rc);
2017
krb5_error_code k5_rc_store(krb5_context context, krb5_rcache rc,
2018
                            const krb5_enc_data *authenticator);
2019
const char *k5_rc_get_name(krb5_context context, krb5_rcache rc);
2020
2021
/* Set *tag_out to the integrity tag of *enc.  (Does not allocate memory;
2022
 * returned buffer is a subrange of *ctext.) */
2023
krb5_error_code
2024
k5_rc_tag_from_ciphertext(krb5_context context, const krb5_enc_data *enc,
2025
                          krb5_data *tag_out);
2026
2027
/*
2028
 * This structure was exposed and used in macros in krb5 1.2, so do not
2029
 * change its ABI.
2030
 */
2031
typedef struct _krb5_kt_ops {
2032
    krb5_magic magic;
2033
    char *prefix;
2034
2035
    /* routines always present */
2036
    krb5_error_code (KRB5_CALLCONV *resolve)(krb5_context, const char *,
2037
                                             krb5_keytab *);
2038
    krb5_error_code (KRB5_CALLCONV *get_name)(krb5_context, krb5_keytab,
2039
                                              char *, unsigned int);
2040
    krb5_error_code (KRB5_CALLCONV *close)(krb5_context, krb5_keytab);
2041
    krb5_error_code (KRB5_CALLCONV *get)(krb5_context, krb5_keytab,
2042
                                         krb5_const_principal, krb5_kvno,
2043
                                         krb5_enctype, krb5_keytab_entry *);
2044
    krb5_error_code (KRB5_CALLCONV *start_seq_get)(krb5_context, krb5_keytab,
2045
                                                   krb5_kt_cursor *);
2046
    krb5_error_code (KRB5_CALLCONV *get_next)(krb5_context, krb5_keytab,
2047
                                              krb5_keytab_entry *,
2048
                                              krb5_kt_cursor *);
2049
    krb5_error_code (KRB5_CALLCONV *end_get)(krb5_context, krb5_keytab,
2050
                                             krb5_kt_cursor *);
2051
    /* routines to be included on extended version (write routines) */
2052
    krb5_error_code (KRB5_CALLCONV *add)(krb5_context, krb5_keytab,
2053
                                         krb5_keytab_entry *);
2054
    krb5_error_code (KRB5_CALLCONV *remove)(krb5_context, krb5_keytab,
2055
                                            krb5_keytab_entry *);
2056
} krb5_kt_ops;
2057
2058
/* Not sure it's ready for exposure just yet.  */
2059
extern krb5_error_code
2060
krb5int_c_mandatory_cksumtype(krb5_context, krb5_enctype, krb5_cksumtype *);
2061
2062
/*
2063
 * Referral definitions and subfunctions.
2064
 */
2065
#define        KRB5_REFERRAL_MAXHOPS    10
2066
2067
struct _krb5_kt {       /* should move into k5-int.h */
2068
    krb5_magic magic;
2069
    const struct _krb5_kt_ops *ops;
2070
    krb5_pointer data;
2071
};
2072
2073
krb5_error_code krb5_get_default_in_tkt_ktypes(krb5_context, krb5_enctype **);
2074
2075
krb5_error_code KRB5_CALLCONV
2076
krb5_get_tgs_ktypes(krb5_context, krb5_const_principal, krb5_enctype **);
2077
2078
krb5_boolean krb5_is_permitted_enctype(krb5_context, krb5_enctype);
2079
2080
krb5_boolean KRB5_CALLCONV krb5int_c_weak_enctype(krb5_enctype);
2081
krb5_boolean KRB5_CALLCONV krb5int_c_deprecated_enctype(krb5_enctype);
2082
krb5_error_code k5_enctype_to_ssf(krb5_enctype enctype, unsigned int *ssf_out);
2083
2084
krb5_error_code krb5_kdc_rep_decrypt_proc(krb5_context, const krb5_keyblock *,
2085
                                          krb5_const_pointer, krb5_kdc_rep *);
2086
krb5_error_code KRB5_CALLCONV krb5_decrypt_tkt_part(krb5_context,
2087
                                                    const krb5_keyblock *,
2088
                                                    krb5_ticket * );
2089
2090
krb5_error_code krb5_get_cred_via_tkt(krb5_context, krb5_creds *, krb5_flags,
2091
                                      krb5_address *const *, krb5_creds *,
2092
                                      krb5_creds **);
2093
2094
krb5_error_code KRB5_CALLCONV krb5_copy_addr(krb5_context,
2095
                                             const krb5_address *,
2096
                                             krb5_address **);
2097
2098
void krb5_init_ets(krb5_context);
2099
void krb5_free_ets(krb5_context);
2100
krb5_error_code krb5_generate_subkey(krb5_context, const krb5_keyblock *,
2101
                                     krb5_keyblock **);
2102
krb5_error_code krb5_generate_subkey_extended(krb5_context,
2103
                                              const krb5_keyblock *,
2104
                                              krb5_enctype, krb5_keyblock **);
2105
krb5_error_code krb5_generate_seq_number(krb5_context, const krb5_keyblock *,
2106
                                         krb5_ui_4 *);
2107
2108
krb5_error_code KRB5_CALLCONV krb5_kt_register(krb5_context,
2109
                                               const struct _krb5_kt_ops *);
2110
2111
krb5_error_code k5_kt_get_principal(krb5_context context, krb5_keytab keytab,
2112
                                    krb5_principal *princ_out);
2113
2114
krb5_error_code k5_kt_have_match(krb5_context context, krb5_keytab keytab,
2115
                                 krb5_principal mprinc);
2116
2117
krb5_error_code krb5_principal2salt_norealm(krb5_context, krb5_const_principal,
2118
                                            krb5_data *);
2119
2120
unsigned int KRB5_CALLCONV krb5_get_notification_message(void);
2121
2122
/* chk_trans.c */
2123
krb5_error_code krb5_check_transited_list(krb5_context, const krb5_data *trans,
2124
                                          const krb5_data *realm1,
2125
                                          const krb5_data *realm2);
2126
2127
/* free_rtree.c */
2128
void krb5_free_realm_tree(krb5_context, krb5_principal *);
2129
2130
void KRB5_CALLCONV krb5_free_authenticator_contents(krb5_context,
2131
                                                    krb5_authenticator *);
2132
2133
void KRB5_CALLCONV krb5_free_address(krb5_context, krb5_address *);
2134
2135
void KRB5_CALLCONV krb5_free_enc_tkt_part(krb5_context, krb5_enc_tkt_part *);
2136
2137
void KRB5_CALLCONV krb5_free_tickets(krb5_context, krb5_ticket **);
2138
void KRB5_CALLCONV krb5_free_kdc_req(krb5_context, krb5_kdc_req *);
2139
void KRB5_CALLCONV krb5_free_kdc_rep(krb5_context, krb5_kdc_rep *);
2140
void KRB5_CALLCONV krb5_free_last_req(krb5_context, krb5_last_req_entry **);
2141
void KRB5_CALLCONV krb5_free_enc_kdc_rep_part(krb5_context,
2142
                                              krb5_enc_kdc_rep_part *);
2143
void KRB5_CALLCONV krb5_free_ap_req(krb5_context, krb5_ap_req *);
2144
void KRB5_CALLCONV krb5_free_ap_rep(krb5_context, krb5_ap_rep *);
2145
void KRB5_CALLCONV krb5_free_cred(krb5_context, krb5_cred *);
2146
void KRB5_CALLCONV krb5_free_cred_enc_part(krb5_context, krb5_cred_enc_part *);
2147
void KRB5_CALLCONV krb5_free_pa_data(krb5_context, krb5_pa_data **);
2148
void KRB5_CALLCONV krb5_free_tkt_authent(krb5_context, krb5_tkt_authent *);
2149
void KRB5_CALLCONV krb5_free_enc_data(krb5_context, krb5_enc_data *);
2150
krb5_error_code krb5_set_config_files(krb5_context, const char **);
2151
2152
krb5_error_code krb5_rd_req_decoded(krb5_context, krb5_auth_context *,
2153
                                    const krb5_ap_req *, krb5_const_principal,
2154
                                    krb5_keytab, krb5_flags *, krb5_ticket **);
2155
2156
krb5_error_code krb5_rd_req_decoded_anyflag(krb5_context, krb5_auth_context *,
2157
                                            const krb5_ap_req *,
2158
                                            krb5_const_principal, krb5_keytab,
2159
                                            krb5_flags *, krb5_ticket **);
2160
2161
krb5_error_code KRB5_CALLCONV
2162
krb5_cc_register(krb5_context, const krb5_cc_ops *, krb5_boolean );
2163
2164
krb5_error_code krb5_walk_realm_tree(krb5_context, const krb5_data *,
2165
                                     const krb5_data *, krb5_principal **,
2166
                                     int);
2167
2168
krb5_error_code
2169
krb5_auth_con_set_safe_cksumtype(krb5_context, krb5_auth_context,
2170
                                 krb5_cksumtype);
2171
2172
krb5_error_code krb5_auth_con_setivector(krb5_context, krb5_auth_context,
2173
                                         krb5_pointer);
2174
2175
krb5_error_code krb5_auth_con_getivector(krb5_context, krb5_auth_context,
2176
                                         krb5_pointer *);
2177
2178
krb5_error_code krb5_auth_con_setpermetypes(krb5_context, krb5_auth_context,
2179
                                            const krb5_enctype *);
2180
2181
krb5_error_code krb5_auth_con_getpermetypes(krb5_context, krb5_auth_context,
2182
                                            krb5_enctype **);
2183
2184
krb5_error_code krb5_auth_con_get_subkey_enctype(krb5_context context,
2185
                                                 krb5_auth_context,
2186
                                                 krb5_enctype *);
2187
2188
krb5_error_code
2189
krb5_auth_con_get_authdata_context(krb5_context context,
2190
                                   krb5_auth_context auth_context,
2191
                                   krb5_authdata_context *ad_context);
2192
2193
krb5_error_code
2194
krb5_auth_con_set_authdata_context(krb5_context context,
2195
                                   krb5_auth_context auth_context,
2196
                                   krb5_authdata_context ad_context);
2197
2198
krb5_error_code krb5_read_message(krb5_context, krb5_pointer, krb5_data *);
2199
krb5_error_code krb5_write_message(krb5_context, krb5_pointer, krb5_data *);
2200
int krb5_net_read(krb5_context, int , char *, int);
2201
int krb5_net_write(krb5_context, int , const char *, int);
2202
2203
krb5_error_code KRB5_CALLCONV krb5_get_realm_domain(krb5_context,
2204
                                                    const char *, char ** );
2205
2206
krb5_error_code krb5_gen_portaddr(krb5_context, const krb5_address *,
2207
                                  krb5_const_pointer, krb5_address **);
2208
2209
krb5_error_code krb5_gen_replay_name(krb5_context, const krb5_address *,
2210
                                     const char *, char **);
2211
krb5_error_code krb5_make_fulladdr(krb5_context, krb5_address *,
2212
                                   krb5_address *, krb5_address *);
2213
2214
krb5_error_code krb5_set_debugging_time(krb5_context, krb5_timestamp,
2215
                                        krb5_int32);
2216
krb5_error_code krb5_use_natural_time(krb5_context);
2217
krb5_error_code krb5_set_time_offsets(krb5_context, krb5_timestamp,
2218
                                      krb5_int32);
2219
2220
/* Some data comparison and conversion functions.  */
2221
static inline int
2222
data_eq(krb5_data d1, krb5_data d2)
2223
0
{
2224
0
    return (d1.length == d2.length && (d1.length == 0 ||
2225
0
                                       !memcmp(d1.data, d2.data, d1.length)));
2226
0
}
Unexecuted instantiation: fuzz_des.c:data_eq
Unexecuted instantiation: f_cksum.c:data_eq
Unexecuted instantiation: f_tables.c:data_eq
Unexecuted instantiation: key_sched.c:data_eq
Unexecuted instantiation: weak_key.c:data_eq
Unexecuted instantiation: f_parity.c:data_eq
Unexecuted instantiation: f_sched.c:data_eq
2227
2228
static inline int
2229
data_eq_string (krb5_data d, const char *s)
2230
0
{
2231
0
    return (d.length == strlen(s) && (d.length == 0 ||
2232
0
                                      !memcmp(d.data, s, d.length)));
2233
0
}
Unexecuted instantiation: fuzz_des.c:data_eq_string
Unexecuted instantiation: f_cksum.c:data_eq_string
Unexecuted instantiation: f_tables.c:data_eq_string
Unexecuted instantiation: key_sched.c:data_eq_string
Unexecuted instantiation: weak_key.c:data_eq_string
Unexecuted instantiation: f_parity.c:data_eq_string
Unexecuted instantiation: f_sched.c:data_eq_string
2234
2235
static inline krb5_data
2236
make_data(void *data, unsigned int len)
2237
0
{
2238
0
    krb5_data d;
2239
0
2240
0
    d.magic = KV5M_DATA;
2241
0
    d.data = (char *) data;
2242
0
    d.length = len;
2243
0
    return d;
2244
0
}
Unexecuted instantiation: fuzz_des.c:make_data
Unexecuted instantiation: f_cksum.c:make_data
Unexecuted instantiation: f_tables.c:make_data
Unexecuted instantiation: key_sched.c:make_data
Unexecuted instantiation: weak_key.c:make_data
Unexecuted instantiation: f_parity.c:make_data
Unexecuted instantiation: f_sched.c:make_data
2245
2246
static inline krb5_data
2247
empty_data(void)
2248
0
{
2249
0
    return make_data(NULL, 0);
2250
0
}
Unexecuted instantiation: fuzz_des.c:empty_data
Unexecuted instantiation: f_cksum.c:empty_data
Unexecuted instantiation: f_tables.c:empty_data
Unexecuted instantiation: key_sched.c:empty_data
Unexecuted instantiation: weak_key.c:empty_data
Unexecuted instantiation: f_parity.c:empty_data
Unexecuted instantiation: f_sched.c:empty_data
2251
2252
static inline krb5_data
2253
string2data(char *str)
2254
0
{
2255
0
    return make_data(str, strlen(str));
2256
0
}
Unexecuted instantiation: fuzz_des.c:string2data
Unexecuted instantiation: f_cksum.c:string2data
Unexecuted instantiation: f_tables.c:string2data
Unexecuted instantiation: key_sched.c:string2data
Unexecuted instantiation: weak_key.c:string2data
Unexecuted instantiation: f_parity.c:string2data
Unexecuted instantiation: f_sched.c:string2data
2257
2258
static inline krb5_error_code
2259
alloc_data(krb5_data *data, unsigned int len)
2260
0
{
2261
0
    /* Allocate at least one byte since zero-byte allocs may return NULL. */
2262
0
    char *ptr = (char *) calloc((len > 0) ? len : 1, 1);
2263
0
2264
0
    if (ptr == NULL)
2265
0
        return ENOMEM;
2266
0
    data->magic = KV5M_DATA;
2267
0
    data->data = ptr;
2268
0
    data->length = len;
2269
0
    return 0;
2270
0
}
Unexecuted instantiation: fuzz_des.c:alloc_data
Unexecuted instantiation: f_cksum.c:alloc_data
Unexecuted instantiation: f_tables.c:alloc_data
Unexecuted instantiation: key_sched.c:alloc_data
Unexecuted instantiation: weak_key.c:alloc_data
Unexecuted instantiation: f_parity.c:alloc_data
Unexecuted instantiation: f_sched.c:alloc_data
2271
2272
static inline int
2273
authdata_eq(krb5_authdata a1, krb5_authdata a2)
2274
0
{
2275
0
    return (a1.ad_type == a2.ad_type && a1.length == a2.length &&
2276
0
            (a1.length == 0 || !memcmp(a1.contents, a2.contents, a1.length)));
2277
0
}
Unexecuted instantiation: fuzz_des.c:authdata_eq
Unexecuted instantiation: f_cksum.c:authdata_eq
Unexecuted instantiation: f_tables.c:authdata_eq
Unexecuted instantiation: key_sched.c:authdata_eq
Unexecuted instantiation: weak_key.c:authdata_eq
Unexecuted instantiation: f_parity.c:authdata_eq
Unexecuted instantiation: f_sched.c:authdata_eq
2278
2279
/* Allocate zeroed memory; set *code to 0 on success or ENOMEM on failure. */
2280
static inline void *
2281
k5calloc(size_t nmemb, size_t size, krb5_error_code *code)
2282
35
{
2283
35
    void *ptr;
2284
2285
    /* Allocate at least one byte since zero-byte allocs may return NULL. */
2286
35
    ptr = calloc(nmemb ? nmemb : 1, size ? size : 1);
2287
35
    *code = (ptr == NULL) ? ENOMEM : 0;
2288
35
    return ptr;
2289
35
}
fuzz_des.c:k5calloc
Line
Count
Source
2282
35
{
2283
35
    void *ptr;
2284
2285
    /* Allocate at least one byte since zero-byte allocs may return NULL. */
2286
35
    ptr = calloc(nmemb ? nmemb : 1, size ? size : 1);
2287
35
    *code = (ptr == NULL) ? ENOMEM : 0;
2288
35
    return ptr;
2289
35
}
Unexecuted instantiation: f_cksum.c:k5calloc
Unexecuted instantiation: f_tables.c:k5calloc
Unexecuted instantiation: key_sched.c:k5calloc
Unexecuted instantiation: weak_key.c:k5calloc
Unexecuted instantiation: f_parity.c:k5calloc
Unexecuted instantiation: f_sched.c:k5calloc
2290
2291
/* Allocate zeroed memory; set *code to 0 on success or ENOMEM on failure. */
2292
static inline void *
2293
k5alloc(size_t size, krb5_error_code *code)
2294
35
{
2295
35
    return k5calloc(1, size, code);
2296
35
}
fuzz_des.c:k5alloc
Line
Count
Source
2294
35
{
2295
35
    return k5calloc(1, size, code);
2296
35
}
Unexecuted instantiation: f_cksum.c:k5alloc
Unexecuted instantiation: f_tables.c:k5alloc
Unexecuted instantiation: key_sched.c:k5alloc
Unexecuted instantiation: weak_key.c:k5alloc
Unexecuted instantiation: f_parity.c:k5alloc
Unexecuted instantiation: f_sched.c:k5alloc
2297
2298
/* Return a copy of the len bytes of memory at in; set *code to 0 or ENOMEM. */
2299
static inline void *
2300
k5memdup(const void *in, size_t len, krb5_error_code *code)
2301
35
{
2302
35
    void *ptr = k5alloc(len, code);
2303
2304
35
    if (ptr != NULL && len > 0)
2305
35
        memcpy(ptr, in, len);
2306
35
    return ptr;
2307
35
}
fuzz_des.c:k5memdup
Line
Count
Source
2301
35
{
2302
35
    void *ptr = k5alloc(len, code);
2303
2304
35
    if (ptr != NULL && len > 0)
2305
35
        memcpy(ptr, in, len);
2306
35
    return ptr;
2307
35
}
Unexecuted instantiation: f_cksum.c:k5memdup
Unexecuted instantiation: f_tables.c:k5memdup
Unexecuted instantiation: key_sched.c:k5memdup
Unexecuted instantiation: weak_key.c:k5memdup
Unexecuted instantiation: f_parity.c:k5memdup
Unexecuted instantiation: f_sched.c:k5memdup
2308
2309
/* Like k5memdup, but add a final null byte. */
2310
static inline void *
2311
k5memdup0(const void *in, size_t len, krb5_error_code *code)
2312
0
{
2313
0
    void *ptr = k5alloc(len + 1, code);
2314
0
2315
0
    if (ptr != NULL && len > 0)
2316
0
        memcpy(ptr, in, len);
2317
0
    return ptr;
2318
0
}
Unexecuted instantiation: fuzz_des.c:k5memdup0
Unexecuted instantiation: f_cksum.c:k5memdup0
Unexecuted instantiation: f_tables.c:k5memdup0
Unexecuted instantiation: key_sched.c:k5memdup0
Unexecuted instantiation: weak_key.c:k5memdup0
Unexecuted instantiation: f_parity.c:k5memdup0
Unexecuted instantiation: f_sched.c:k5memdup0
2319
2320
/* memcpy if len > 0, to avoid passing null pointers (which is undefined). */
2321
static inline void
2322
k5memcpy(void *dest, const void *src, size_t len)
2323
0
{
2324
0
    if (len > 0)
2325
0
        memcpy(dest, src, len);
2326
0
}
Unexecuted instantiation: fuzz_des.c:k5memcpy
Unexecuted instantiation: f_cksum.c:k5memcpy
Unexecuted instantiation: f_tables.c:k5memcpy
Unexecuted instantiation: key_sched.c:k5memcpy
Unexecuted instantiation: weak_key.c:k5memcpy
Unexecuted instantiation: f_parity.c:k5memcpy
Unexecuted instantiation: f_sched.c:k5memcpy
2327
2328
/* memmove if len > 0, to avoid passing null pointers (which is undefined). */
2329
static inline void
2330
k5memmove(void *dest, const void *src, size_t len)
2331
0
{
2332
0
    if (len > 0)
2333
0
        memmove(dest, src, len);
2334
0
}
Unexecuted instantiation: fuzz_des.c:k5memmove
Unexecuted instantiation: f_cksum.c:k5memmove
Unexecuted instantiation: f_tables.c:k5memmove
Unexecuted instantiation: key_sched.c:k5memmove
Unexecuted instantiation: weak_key.c:k5memmove
Unexecuted instantiation: f_parity.c:k5memmove
Unexecuted instantiation: f_sched.c:k5memmove
2335
2336
/* Convert a krb5_timestamp to a time_t value, treating the negative range of
2337
 * krb5_timestamp as times between 2038 and 2106 (if time_t is 64-bit). */
2338
static inline time_t
2339
ts2tt(krb5_timestamp timestamp)
2340
0
{
2341
0
    return (time_t)(uint32_t)timestamp;
2342
0
}
Unexecuted instantiation: fuzz_des.c:ts2tt
Unexecuted instantiation: f_cksum.c:ts2tt
Unexecuted instantiation: f_tables.c:ts2tt
Unexecuted instantiation: key_sched.c:ts2tt
Unexecuted instantiation: weak_key.c:ts2tt
Unexecuted instantiation: f_parity.c:ts2tt
Unexecuted instantiation: f_sched.c:ts2tt
2343
2344
/* Return the delta between two timestamps (a - b) as a signed 32-bit value,
2345
 * without relying on undefined behavior. */
2346
static inline krb5_deltat
2347
ts_delta(krb5_timestamp a, krb5_timestamp b)
2348
0
{
2349
0
    return (krb5_deltat)((uint32_t)a - (uint32_t)b);
2350
0
}
Unexecuted instantiation: fuzz_des.c:ts_delta
Unexecuted instantiation: f_cksum.c:ts_delta
Unexecuted instantiation: f_tables.c:ts_delta
Unexecuted instantiation: key_sched.c:ts_delta
Unexecuted instantiation: weak_key.c:ts_delta
Unexecuted instantiation: f_parity.c:ts_delta
Unexecuted instantiation: f_sched.c:ts_delta
2351
2352
/* Return (end - start) as an unsigned 32-bit value, or 0 if start > end. */
2353
static inline uint32_t
2354
ts_interval(krb5_timestamp start, krb5_timestamp end)
2355
0
{
2356
0
    if ((uint32_t)start > (uint32_t)end)
2357
0
        return 0;
2358
0
    return (uint32_t)end - (uint32_t)start;
2359
0
}
Unexecuted instantiation: fuzz_des.c:ts_interval
Unexecuted instantiation: f_cksum.c:ts_interval
Unexecuted instantiation: f_tables.c:ts_interval
Unexecuted instantiation: key_sched.c:ts_interval
Unexecuted instantiation: weak_key.c:ts_interval
Unexecuted instantiation: f_parity.c:ts_interval
Unexecuted instantiation: f_sched.c:ts_interval
2360
2361
/* Increment a timestamp by a signed 32-bit interval, without relying on
2362
 * undefined behavior. */
2363
static inline krb5_timestamp
2364
ts_incr(krb5_timestamp ts, krb5_deltat delta)
2365
0
{
2366
0
    return (krb5_timestamp)((uint32_t)ts + (uint32_t)delta);
2367
0
}
Unexecuted instantiation: fuzz_des.c:ts_incr
Unexecuted instantiation: f_cksum.c:ts_incr
Unexecuted instantiation: f_tables.c:ts_incr
Unexecuted instantiation: key_sched.c:ts_incr
Unexecuted instantiation: weak_key.c:ts_incr
Unexecuted instantiation: f_parity.c:ts_incr
Unexecuted instantiation: f_sched.c:ts_incr
2368
2369
/* Return true if a comes after b. */
2370
static inline krb5_boolean
2371
ts_after(krb5_timestamp a, krb5_timestamp b)
2372
0
{
2373
0
    return (uint32_t)a > (uint32_t)b;
2374
0
}
Unexecuted instantiation: fuzz_des.c:ts_after
Unexecuted instantiation: f_cksum.c:ts_after
Unexecuted instantiation: f_tables.c:ts_after
Unexecuted instantiation: key_sched.c:ts_after
Unexecuted instantiation: weak_key.c:ts_after
Unexecuted instantiation: f_parity.c:ts_after
Unexecuted instantiation: f_sched.c:ts_after
2375
2376
/* Return true if a and b are within d seconds. */
2377
static inline krb5_boolean
2378
ts_within(krb5_timestamp a, krb5_timestamp b, krb5_deltat d)
2379
0
{
2380
0
    return !ts_after(a, ts_incr(b, d)) && !ts_after(b, ts_incr(a, d));
2381
0
}
Unexecuted instantiation: fuzz_des.c:ts_within
Unexecuted instantiation: f_cksum.c:ts_within
Unexecuted instantiation: f_tables.c:ts_within
Unexecuted instantiation: key_sched.c:ts_within
Unexecuted instantiation: weak_key.c:ts_within
Unexecuted instantiation: f_parity.c:ts_within
Unexecuted instantiation: f_sched.c:ts_within
2382
2383
krb5_error_code KRB5_CALLCONV
2384
krb5_get_credentials_for_user(krb5_context context, krb5_flags options,
2385
                              krb5_ccache ccache,
2386
                              krb5_creds *in_creds,
2387
                              krb5_data *cert,
2388
                              krb5_creds **out_creds);
2389
2390
krb5_error_code KRB5_CALLCONV
2391
krb5_get_credentials_for_proxy(krb5_context context,
2392
                               krb5_flags options,
2393
                               krb5_ccache ccache,
2394
                               krb5_creds *in_creds,
2395
                               krb5_ticket *evidence_tkt,
2396
                               krb5_creds **out_creds);
2397
2398
krb5_error_code KRB5_CALLCONV
2399
krb5int_get_authdata_containee_types(krb5_context context,
2400
                                     const krb5_authdata *container,
2401
                                     unsigned int *nad_types,
2402
                                     krb5_authdatatype **ad_types);
2403
2404
krb5_error_code krb5int_parse_enctype_list(krb5_context context,
2405
                                           const char *profkey, char *profstr,
2406
                                           krb5_enctype *default_list,
2407
                                           krb5_enctype **result);
2408
2409
krb5_boolean k5_etypes_contains(const krb5_enctype *list, krb5_enctype etype);
2410
2411
void k5_change_error_message_code(krb5_context ctx, krb5_error_code oldcode,
2412
                                  krb5_error_code newcode);
2413
2414
/* Define shorter internal names for setting error messages. */
2415
#define k5_setmsg krb5_set_error_message
2416
#define k5_prependmsg krb5_prepend_error_message
2417
#define k5_wrapmsg krb5_wrap_error_message
2418
2419
/*
2420
 * Like krb5_principal_compare(), but with canonicalization of sname if
2421
 * fallback is enabled.  This function should be avoided if multiple matches
2422
 * are required, since repeated canonicalization is inefficient.
2423
 */
2424
krb5_boolean
2425
k5_sname_compare(krb5_context context, krb5_const_principal sname,
2426
                 krb5_const_principal princ);
2427
2428
/* Generate an HMAC-MD5 keyed checksum as specified by RFC 2104. */
2429
krb5_error_code
2430
k5_hmac_md5(const krb5_data *key, const krb5_crypto_iov *data, size_t num_data,
2431
            krb5_data *output);
2432
2433
/* Address objects for initiator and acceptor directional addresses. */
2434
extern const krb5_address k5_addr_directional_init;
2435
extern const krb5_address k5_addr_directional_accept;
2436
2437
/*
2438
 * Translate sa to a krb5_address, putting the result in *out with contents
2439
 * aliased from *sa.  If local_use is true, translate UNIX domain socket names
2440
 * to ADDRTYPE_UNIXSOCK; otherwise do not handle them.  Return
2441
 * KRB5_PROG_ATYPE_NOSUPP if sa cannot be converted.
2442
 */
2443
krb5_error_code
2444
k5_sockaddr_to_address(const struct sockaddr *sa, krb5_boolean local_use,
2445
                       krb5_address *out);
2446
2447
/* Place a printable representation of sa (without port) into buf. */
2448
void
2449
k5_print_addr(const struct sockaddr *sa, char *buf, size_t len);
2450
2451
/* Place a printable representation of sa (with port) into buf. */
2452
void
2453
k5_print_addr_port(const struct sockaddr *sa, char *buf, size_t len);
2454
2455
#endif /* _KRB5_INT_H */