Coverage Report

Created: 2026-04-01 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/samba/lib/krb5_wrap/krb5_samba.h
Line
Count
Source
1
/*
2
   Unix SMB/CIFS implementation.
3
   simple kerberos5 routines for active directory
4
   Copyright (C) Andrew Tridgell 2001
5
   Copyright (C) Luke Howard 2002-2003
6
   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
7
   Copyright (C) Guenther Deschner 2005-2009
8
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3 of the License, or
12
   (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
*/
22
23
#ifndef _KRB5_SAMBA_H
24
#define _KRB5_SAMBA_H
25
26
#include "lib/util/data_blob.h"
27
#include "libcli/util/ntstatus.h"
28
#include "lib/util/talloc_stack.h"
29
#include "lib/util/debug.h"
30
31
#ifdef HAVE_KRB5
32
33
#define KRB5_PRIVATE    1       /* this file uses PRIVATE interfaces! */
34
/* this file uses DEPRECATED interfaces! */
35
36
#ifdef KRB5_DEPRECATED
37
#undef KRB5_DEPRECATED
38
#endif
39
40
#if defined(HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER)
41
#define KRB5_DEPRECATED 1
42
#else
43
#define KRB5_DEPRECATED
44
#endif
45
46
#include "system/kerberos.h"
47
#include "system/network.h"
48
49
#ifndef KRB5_ADDR_NETBIOS
50
0
#define KRB5_ADDR_NETBIOS 0x14
51
#endif
52
53
#ifndef KRB5KRB_ERR_RESPONSE_TOO_BIG
54
#define KRB5KRB_ERR_RESPONSE_TOO_BIG (-1765328332L)
55
#endif
56
57
/* Heimdal uses a slightly different name */
58
#if defined(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5) && !defined(HAVE_ENCTYPE_ARCFOUR_HMAC)
59
#define ENCTYPE_ARCFOUR_HMAC ENCTYPE_ARCFOUR_HMAC_MD5
60
#endif
61
#if defined(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5_56) && !defined(HAVE_ENCTYPE_ARCFOUR_HMAC_EXP)
62
0
#define ENCTYPE_ARCFOUR_HMAC_EXP ENCTYPE_ARCFOUR_HMAC_MD5_56
63
#endif
64
65
/* The older versions of heimdal that don't have this
66
   define don't seem to use it anyway.  I'm told they
67
   always use a subkey */
68
#ifndef HAVE_AP_OPTS_USE_SUBKEY
69
#define AP_OPTS_USE_SUBKEY 0
70
#endif
71
72
#ifndef KRB5_PW_SALT
73
0
#define KRB5_PW_SALT 3
74
#endif
75
76
/* CKSUMTYPE_HMAC_MD5 in Heimdal
77
   CKSUMTYPE_HMAC_MD5_ARCFOUR in MIT */
78
#if defined(CKSUMTYPE_HMAC_MD5_ARCFOUR) && !defined(CKSUMTYPE_HMAC_MD5)
79
#define CKSUMTYPE_HMAC_MD5 CKSUMTYPE_HMAC_MD5_ARCFOUR
80
#endif
81
82
/*
83
 * CKSUMTYPE_HMAC_SHA1_96_AES_* in Heimdal
84
 * CKSUMTYPE_HMAC_SHA1_96_AES* in MIT
85
 */
86
#if defined(CKSUMTYPE_HMAC_SHA1_96_AES128) && !defined(CKSUMTYPE_HMAC_SHA1_96_AES_128)
87
#define CKSUMTYPE_HMAC_SHA1_96_AES_128 CKSUMTYPE_HMAC_SHA1_96_AES128
88
#endif
89
#if defined(CKSUMTYPE_HMAC_SHA1_96_AES256) && !defined(CKSUMTYPE_HMAC_SHA1_96_AES_256)
90
#define CKSUMTYPE_HMAC_SHA1_96_AES_256 CKSUMTYPE_HMAC_SHA1_96_AES256
91
#endif
92
93
/*
94
 * RFC8009 encryption types' defines have different names:
95
 *
96
 * KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128 in Heimdal
97
 * ENCTYPE_AES128_CTS_HMAC_SHA256_128 in MIT
98
 *
99
 * and
100
 *
101
 * KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192 in Heimdal
102
 * ENCTYPE_AES256_CTS_HMAC_SHA384_192 in MIT
103
 */
104
#if !defined(ENCTYPE_AES128_CTS_HMAC_SHA256_128)
105
0
#define ENCTYPE_AES128_CTS_HMAC_SHA256_128 KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128
106
#endif
107
#if !defined(ENCTYPE_AES256_CTS_HMAC_SHA384_192)
108
0
#define ENCTYPE_AES256_CTS_HMAC_SHA384_192 KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192
109
#endif
110
111
/*
112
 * Same for older encryption types, rename to have the same defines
113
 */
114
#if !defined(ENCTYPE_AES128_CTS_HMAC_SHA1_96)
115
#define ENCTYPE_AES128_CTS_HMAC_SHA1_96 KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96
116
#endif
117
#if !defined(ENCTYPE_AES256_CTS_HMAC_SHA1_96)
118
#define ENCTYPE_AES256_CTS_HMAC_SHA1_96 KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96
119
#endif
120
121
/*
122
 * KRB5_KU_OTHER_ENCRYPTED in Heimdal
123
 * KRB5_KEYUSAGE_APP_DATA_ENCRYPT in MIT
124
 */
125
#if defined(KRB5_KEYUSAGE_APP_DATA_ENCRYPT) && !defined(KRB5_KU_OTHER_ENCRYPTED)
126
#define KRB5_KU_OTHER_ENCRYPTED KRB5_KEYUSAGE_APP_DATA_ENCRYPT
127
#endif
128
129
typedef struct {
130
#if defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) /* MIT */
131
  krb5_address **addrs;
132
#elif defined(HAVE_KRB5_ADDRESSES) /* Heimdal */
133
  krb5_addresses *addrs;
134
#else
135
#error UNKNOWN_KRB5_ADDRESS_TYPE
136
#endif /* defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) */
137
} smb_krb5_addresses;
138
139
#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY               /* MIT */
140
#define KRB5_KT_KEY(k)    (&(k)->key)
141
#elif defined(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK)  /* Heimdal */
142
0
#define KRB5_KT_KEY(k)    (&(k)->keyblock)
143
#else
144
#error krb5_keytab_entry has no key or keyblock member
145
#endif /* HAVE_KRB5_KEYTAB_ENTRY_KEY */
146
147
/* work around broken krb5.h on sles9 */
148
#ifdef SIZEOF_LONG
149
#undef SIZEOF_LONG
150
#endif
151
152
#ifdef HAVE_KRB5_KEYBLOCK_KEYVALUE /* Heimdal */
153
0
#define KRB5_KEY_TYPE(k)  ((k)->keytype)
154
0
#define KRB5_KEY_LENGTH(k)  ((k)->keyvalue.length)
155
0
#define KRB5_KEY_DATA(k)  ((k)->keyvalue.data)
156
#define KRB5_KEY_DATA_CAST  void
157
#else /* MIT */
158
#define KRB5_KEY_TYPE(k)  ((k)->enctype)
159
#define KRB5_KEY_LENGTH(k)  ((k)->length)
160
#define KRB5_KEY_DATA(k)  ((k)->contents)
161
#define KRB5_KEY_DATA_CAST  krb5_octet
162
#endif /* HAVE_KRB5_KEYBLOCK_KEYVALUE */
163
164
#ifdef HAVE_E_DATA_POINTER_IN_KRB5_ERROR /* Heimdal */
165
#define KRB5_ERROR_CODE(k)  ((k)->error_code)
166
#else /* MIT */
167
#define KRB5_ERROR_CODE(k)  ((k)->error)
168
#endif /* HAVE_E_DATA_POINTER_IN_KRB5_ERROR */
169
170
#ifndef HAVE_KRB5_CONST_PAC
171
#ifdef KRB5_CONST_PAC_GET_BUFFER
172
typedef const struct krb5_pac_data *krb5_const_pac;
173
#else
174
/*
175
 * Certain Heimdal versions include a version of krb5_pac_get_buffer() that is
176
 * unusable in certain cases, taking a krb5_pac when a krb5_const_pac may be all
177
 * that we can supply. Furthermore, MIT Kerberos doesn't declare krb5_const_pac
178
 * at all. In such cases, we must declare krb5_const_pac as a non-const typedef
179
 * so that the build can succeed.
180
 */
181
typedef struct krb5_pac_data *krb5_const_pac;
182
#endif
183
#endif
184
185
krb5_error_code smb_krb5_parse_name(krb5_context context,
186
        const char *name, /* in unix charset */
187
                                krb5_principal *principal);
188
189
krb5_error_code smb_krb5_parse_name_flags(krb5_context context,
190
            const char *name, /* unix charset */
191
            int flags,
192
            krb5_principal *principal);
193
194
krb5_error_code smb_krb5_unparse_name(TALLOC_CTX *mem_ctx,
195
              krb5_context context,
196
              krb5_const_principal principal,
197
              char **unix_name);
198
199
static inline void samba_trace_keytab_entry(krb5_context context,
200
            krb5_keytab_entry kt_entry,
201
            const char *func,
202
            int line,
203
            const char *op)
204
0
{
205
0
  char *princ_s = NULL;
206
0
#define MAX_KEYLEN 64
207
0
  char tmp[2 * MAX_KEYLEN + 1] = { 0, };
208
0
  krb5_enctype enctype = 0;
209
0
  krb5_keyblock *key = NULL;
210
0
  TALLOC_CTX *frame = talloc_stackframe();
211
0
  krb5_error_code code;
212
0
  const uint8_t *ptr = NULL;
213
0
  unsigned len, i;
214
215
0
  code = smb_krb5_unparse_name(frame,
216
0
             context,
217
0
             kt_entry.principal,
218
0
             &princ_s);
219
0
  if (code != 0) {
220
0
    goto out;
221
0
  }
222
0
  enctype = KRB5_KEY_TYPE(KRB5_KT_KEY(&kt_entry));
223
0
  key = KRB5_KT_KEY(&kt_entry);
224
0
#ifdef DEBUG_PASSWORD
225
0
  ptr = (const uint8_t *) KRB5_KEY_DATA(key);
226
0
  len = KRB5_KEY_LENGTH(key);
227
228
0
  for (i = 0; i < len && i < MAX_KEYLEN; i++) {
229
0
    snprintf(&tmp[2 * i], 3, "%02X", ptr[i]);
230
0
  }
231
#else
232
  tmp[0] = 0;
233
#endif
234
0
  DEBUG(10,("KEYTAB_TRACE %36s:%-4d %3s %78s %3d %2d %s\n",
235
0
      func,
236
0
      line,
237
0
      op,
238
0
      princ_s,
239
0
      kt_entry.vno,
240
0
      enctype,
241
0
      tmp));
242
0
out:
243
0
  TALLOC_FREE(frame);
244
0
}
Unexecuted instantiation: krb5_init_context.c:samba_trace_keytab_entry
Unexecuted instantiation: credentials_krb5.c:samba_trace_keytab_entry
Unexecuted instantiation: krb5_samba.c:samba_trace_keytab_entry
Unexecuted instantiation: gss_samba.c:samba_trace_keytab_entry
Unexecuted instantiation: keytab_util.c:samba_trace_keytab_entry
Unexecuted instantiation: enctype_convert.c:samba_trace_keytab_entry
Unexecuted instantiation: krb5_errs.c:samba_trace_keytab_entry
Unexecuted instantiation: kerberos_pac.c:samba_trace_keytab_entry
Unexecuted instantiation: cracknames.c:samba_trace_keytab_entry
Unexecuted instantiation: kerberos_util.c:samba_trace_keytab_entry
Unexecuted instantiation: gssapi_pac.c:samba_trace_keytab_entry
Unexecuted instantiation: gssapi_helper.c:samba_trace_keytab_entry
Unexecuted instantiation: srv_keytab.c:samba_trace_keytab_entry
Unexecuted instantiation: gensec_gssapi.c:samba_trace_keytab_entry
Unexecuted instantiation: auth_generic.c:samba_trace_keytab_entry
Unexecuted instantiation: pac-glue.c:samba_trace_keytab_entry
Unexecuted instantiation: pac-blobs.c:samba_trace_keytab_entry
Unexecuted instantiation: sasl.c:samba_trace_keytab_entry
Unexecuted instantiation: krb5_setpw.c:samba_trace_keytab_entry
Unexecuted instantiation: kerberos_keytab.c:samba_trace_keytab_entry
Unexecuted instantiation: trusts_util.c:samba_trace_keytab_entry
Unexecuted instantiation: kerberos.c:samba_trace_keytab_entry
Unexecuted instantiation: ads_status.c:samba_trace_keytab_entry
Unexecuted instantiation: db-glue.c:samba_trace_keytab_entry
Unexecuted instantiation: sdb.c:samba_trace_keytab_entry
Unexecuted instantiation: auth.c:samba_trace_keytab_entry
Unexecuted instantiation: authdata.c:samba_trace_keytab_entry
Unexecuted instantiation: machine_account_secrets.c:samba_trace_keytab_entry
Unexecuted instantiation: smb_seal.c:samba_trace_keytab_entry
Unexecuted instantiation: auth_sam.c:samba_trace_keytab_entry
Unexecuted instantiation: libnet_keytab.c:samba_trace_keytab_entry
Unexecuted instantiation: gse_krb5.c:samba_trace_keytab_entry
Unexecuted instantiation: gse.c:samba_trace_keytab_entry
245
246
#if defined(__GNUC__) && defined(DEVELOPER)
247
/* http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html */
248
249
#define samba_krb5_kt_add_entry(context, id, entry)                          \
250
0
  ({                                                                   \
251
0
    krb5_error_code _code;                                       \
252
0
    _code = krb5_kt_add_entry((context), (id), (entry));         \
253
0
    if (CHECK_DEBUGLVL(10)) {                                    \
254
0
      samba_trace_keytab_entry((context),                  \
255
0
             *(entry),                   \
256
0
             __func__,                   \
257
0
             __LINE__,                   \
258
0
             _code == 0 ? "add"          \
259
0
                  : "add FAILED"); \
260
0
    }                                                            \
261
0
    _code;                                                       \
262
0
  })
263
264
#define samba_krb5_kt_remove_entry(context, id, entry)                       \
265
0
  ({                                                                   \
266
0
    krb5_error_code _code;                                       \
267
0
    _code = krb5_kt_remove_entry((context), (id), (entry));      \
268
0
    if (CHECK_DEBUGLVL(10)) {                                    \
269
0
      samba_trace_keytab_entry((context),                  \
270
0
             *(entry),                   \
271
0
             __func__,                   \
272
0
             __LINE__,                   \
273
0
             _code == 0 ? "rem"          \
274
0
                  : "rem FAILED"); \
275
0
    }                                                            \
276
0
    _code;                                                       \
277
0
  })
278
279
#define samba_krb5_kt_next_entry(context, id, entry, cursor) \
280
0
  ({                                                   \
281
0
    krb5_error_code _code;                       \
282
0
    _code = krb5_kt_next_entry((context),        \
283
0
             (id),             \
284
0
             (entry),          \
285
0
             (cursor));        \
286
0
    if (_code == 0 && CHECK_DEBUGLVL(10)) {      \
287
0
      samba_trace_keytab_entry((context),  \
288
0
             *(entry),   \
289
0
             __func__,   \
290
0
             __LINE__,   \
291
0
             "nxt");     \
292
0
    }                                            \
293
0
    _code;                                       \
294
0
  })
295
296
#else
297
298
#define samba_krb5_kt_add_entry(context, id, entry) \
299
  krb5_kt_add_entry((context), (id), (entry))
300
#define samba_krb5_kt_remove_entry(context, id, entry) \
301
  krb5_kt_remove_entry((context), (id), (entry))
302
#define samba_krb5_kt_next_entry(context, id, entry, cursor) \
303
  krb5_kt_next_entry((context), (id), (entry), (cursor))
304
305
#endif
306
307
krb5_error_code smb_krb5_init_context_common(krb5_context *_krb5_context);
308
309
/*
310
 * This should only be used in code that
311
 * really wants to touch the global default ccache!
312
 */
313
krb5_error_code smb_force_krb5_cc_default(krb5_context ctx, krb5_ccache *id);
314
/*
315
 * This should only be used in code that
316
 * really wants to touch the global default ccache!
317
 */
318
const char *smb_force_krb5_cc_default_name(krb5_context ctx);
319
320
/*
321
 * Read the default ccache name from krb5.conf without expanding tokens
322
 * like %{uid}. Returns the raw configured value.
323
 */
324
krb5_error_code smb_krb5_config_cc_default_name(TALLOC_CTX *mem_ctx,
325
            krb5_context ctx,
326
            char **pname);
327
328
krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc);
329
330
#if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
331
krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock *keyblock);
332
#endif
333
334
#ifndef HAVE_KRB5_FREE_UNPARSED_NAME
335
void krb5_free_unparsed_name(krb5_context ctx, char *val);
336
#endif
337
338
#if !defined(HAVE_KRB5_FREE_ENCTYPES)
339
void krb5_free_enctypes(krb5_context context, krb5_enctype *val);
340
#endif
341
342
#if !defined(HAVE_KRB5_FREE_STRING)
343
void krb5_free_string(krb5_context context, char *val);
344
#endif
345
346
/* Stub out initialize_krb5_error_table since it is not present in all
347
 * Kerberos implementations. If it's not present, it's not necessary to
348
 * call it.
349
 */
350
#ifndef HAVE_INITIALIZE_KRB5_ERROR_TABLE
351
#define initialize_krb5_error_table()
352
#endif
353
354
/* Samba wrapper functions for krb5 functionality. */
355
bool smb_krb5_sockaddr_to_kaddr(struct sockaddr_storage *paddr,
356
        krb5_address *pkaddr);
357
358
krb5_error_code smb_krb5_mk_error(krb5_context context,
359
          krb5_error_code error_code,
360
          const char *e_text,
361
          krb5_data *e_data,
362
          const krb5_principal client,
363
          const krb5_principal server,
364
          krb5_data *enc_err);
365
366
krb5_error_code smb_krb5_get_allowed_etypes(krb5_context context,
367
              krb5_enctype **enctypes);
368
369
bool smb_krb5_get_smb_session_key(TALLOC_CTX *mem_ctx,
370
          krb5_context context,
371
          krb5_auth_context auth_context,
372
          DATA_BLOB *session_key,
373
          bool remote);
374
375
krb5_error_code smb_krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *kt_entry);
376
void smb_krb5_free_data_contents(krb5_context context, krb5_data *pdata);
377
krb5_error_code smb_krb5_renew_ticket(const char *ccache_string, const char *client_string, const char *service_string, time_t *expire_time);
378
krb5_error_code smb_krb5_gen_netbios_krb5_address(smb_krb5_addresses **kerb_addr,
379
              const char *netbios_name);
380
krb5_error_code smb_krb5_free_addresses(krb5_context context, smb_krb5_addresses *addr);
381
krb5_enctype smb_krb5_kt_get_enctype_from_entry(krb5_keytab_entry *kt_entry);
382
383
krb5_error_code smb_krb5_enctype_to_string(krb5_context context,
384
              krb5_enctype enctype,
385
              char **etype_s);
386
krb5_error_code smb_krb5_kt_open_relative(krb5_context context,
387
            const char *keytab_name_req,
388
            bool write_access,
389
            krb5_keytab *keytab);
390
krb5_error_code smb_krb5_kt_open(krb5_context context,
391
         const char *keytab_name,
392
         bool write_access,
393
         krb5_keytab *keytab);
394
krb5_error_code smb_krb5_kt_get_name(TALLOC_CTX *mem_ctx,
395
             krb5_context context,
396
             krb5_keytab keytab,
397
             const char **keytab_name);
398
krb5_error_code smb_krb5_kt_seek_and_delete_old_entries(krb5_context context,
399
              krb5_keytab keytab,
400
              bool keep_old_kvno,
401
              krb5_kvno kvno,
402
              bool enctype_only,
403
              krb5_enctype enctype,
404
              const char *princ_s,
405
              krb5_principal princ,
406
              bool flush);
407
408
krb5_error_code smb_krb5_get_credentials(krb5_context context,
409
           krb5_ccache ccache,
410
           krb5_principal me,
411
           krb5_principal server,
412
           krb5_principal impersonate_princ,
413
           krb5_creds **out_creds);
414
krb5_error_code smb_krb5_keyblock_init_contents(krb5_context context,
415
            krb5_enctype enctype,
416
            const void *data,
417
            size_t length,
418
            krb5_keyblock *key);
419
krb5_error_code smb_krb5_kinit_keyblock_ccache(krb5_context ctx,
420
                 krb5_ccache cc,
421
                 krb5_principal principal,
422
                 krb5_keyblock *keyblock,
423
                 const char *target_service,
424
                 krb5_get_init_creds_opt *krb_options,
425
                 time_t *expire_time,
426
                 time_t *kdc_time);
427
krb5_error_code smb_krb5_kinit_password_ccache(krb5_context ctx,
428
                 krb5_ccache cc,
429
                 krb5_principal principal,
430
                 const char *password,
431
                 const char *target_service,
432
                 krb5_get_init_creds_opt *krb_options,
433
                 time_t *expire_time,
434
                 time_t *kdc_time);
435
krb5_error_code smb_krb5_kinit_s4u2_ccache(krb5_context ctx,
436
             krb5_ccache store_cc,
437
             krb5_principal init_principal,
438
             const char *init_password,
439
             krb5_principal impersonate_principal,
440
             const char *self_service,
441
             const char *target_service,
442
             krb5_get_init_creds_opt *krb_options,
443
             time_t *expire_time,
444
             time_t *kdc_time);
445
446
#if defined(HAVE_KRB5_MAKE_PRINCIPAL)
447
0
#define smb_krb5_make_principal krb5_make_principal
448
#elif defined(HAVE_KRB5_BUILD_PRINCIPAL_ALLOC_VA)
449
krb5_error_code smb_krb5_make_principal(krb5_context context,
450
          krb5_principal *principal,
451
          const char *realm, ...);
452
#else
453
#error krb5_make_principal not available
454
#endif
455
456
#if defined(HAVE_KRB5_CC_GET_LIFETIME)
457
0
#define smb_krb5_cc_get_lifetime krb5_cc_get_lifetime
458
#elif defined(HAVE_KRB5_CC_RETRIEVE_CRED)
459
krb5_error_code smb_krb5_cc_get_lifetime(krb5_context context,
460
           krb5_ccache id,
461
           time_t *t);
462
#else
463
#error krb5_cc_get_lifetime not available
464
#endif
465
466
#if defined(HAVE_KRB5_FREE_CHECKSUM_CONTENTS)
467
#define smb_krb5_free_checksum_contents krb5_free_checksum_contents
468
#elif defined (HAVE_FREE_CHECKSUM)
469
void smb_krb5_free_checksum_contents(krb5_context ctx, krb5_checksum *cksum);
470
#else
471
#error krb5_free_checksum_contents/free_Checksum is not available
472
#endif
473
474
krb5_error_code smb_krb5_make_pac_checksum(TALLOC_CTX *mem_ctx,
475
             DATA_BLOB *pac_data,
476
             krb5_context context,
477
             const krb5_keyblock *keyblock,
478
             uint32_t *sig_type,
479
             DATA_BLOB *sig_blob);
480
481
char *smb_krb5_principal_get_realm(TALLOC_CTX *mem_ctx,
482
           krb5_context context,
483
           krb5_const_principal principal);
484
485
void smb_krb5_principal_set_type(krb5_context context,
486
         krb5_principal principal,
487
         int type);
488
489
int smb_krb5_principal_is_tgs(krb5_context context,
490
            krb5_const_principal principal);
491
492
krb5_error_code smb_krb5_principal_set_realm(krb5_context context,
493
               krb5_principal principal,
494
               const char *realm);
495
496
char *smb_krb5_get_realm_from_hostname(TALLOC_CTX *mem_ctx,
497
               const char *hostname,
498
               const char *client_realm);
499
500
char *smb_get_krb5_error_message(krb5_context context,
501
         krb5_error_code code,
502
         TALLOC_CTX *mem_ctx);
503
504
#if defined(HAVE_KRB5_KT_COMPARE)
505
0
#define smb_krb5_kt_compare krb5_kt_compare
506
#else
507
krb5_boolean smb_krb5_kt_compare(krb5_context context,
508
         krb5_keytab_entry *entry,
509
         krb5_const_principal principal,
510
         krb5_kvno vno,
511
         krb5_enctype enctype);
512
#endif
513
514
const krb5_enctype *samba_all_enctypes(void);
515
516
uint32_t kerberos_enctype_to_bitmap(krb5_enctype enc_type_enum);
517
krb5_enctype ms_suptype_to_ietf_enctype(uint32_t enctype_bitmap);
518
krb5_error_code ms_suptypes_to_ietf_enctypes(TALLOC_CTX *mem_ctx,
519
               uint32_t enctype_bitmap,
520
               krb5_enctype **enctypes);
521
int smb_krb5_get_pw_salt(krb5_context context,
522
       krb5_const_principal host_princ,
523
       krb5_data *psalt);
524
int smb_krb5_salt_principal(krb5_context krb5_ctx,
525
          const char *realm,
526
          const char *sAMAccountName,
527
          const char *userPrincipalName,
528
          uint32_t uac_flags,
529
          krb5_principal *salt_princ);
530
531
int smb_krb5_salt_principal_str(const char *realm,
532
        const char *sAMAccountName,
533
        const char *userPrincipalName,
534
        uint32_t uac_flags,
535
        TALLOC_CTX *mem_ctx,
536
        char **_salt_principal);
537
int smb_krb5_salt_principal2data(krb5_context context,
538
         const char *salt_principal,
539
         TALLOC_CTX *mem_ctx,
540
         char **_salt_data);
541
542
int smb_krb5_create_key_from_string(krb5_context context,
543
            krb5_const_principal host_princ,
544
            const krb5_data *salt,
545
            const krb5_data *password,
546
            krb5_enctype enctype,
547
            krb5_keyblock *key);
548
549
#ifndef krb5_princ_size
550
#if defined(HAVE_KRB5_PRINCIPAL_GET_NUM_COMP)
551
0
#define krb5_princ_size krb5_principal_get_num_comp
552
#else
553
#error krb5_princ_size unavailable
554
#endif
555
#endif
556
557
krb5_error_code smb_krb5_principal_get_comp_string(TALLOC_CTX *mem_ctx,
558
               krb5_context context,
559
               krb5_const_principal principal,
560
               unsigned int component,
561
               char **out);
562
563
krb5_error_code smb_krb5_copy_data_contents(krb5_data *p,
564
              const void *data,
565
              size_t len);
566
567
krb5_data smb_krb5_make_data(void *data,
568
           size_t len);
569
570
krb5_data smb_krb5_data_from_blob(DATA_BLOB blob);
571
572
int smb_krb5_principal_get_type(krb5_context context,
573
        krb5_const_principal principal);
574
575
#if !defined(HAVE_KRB5_WARNX)
576
krb5_error_code krb5_warnx(krb5_context context, const char *fmt, ...)
577
  PRINTF_ATTRIBUTE(2, 0);
578
#endif
579
580
krb5_error_code smb_krb5_cc_new_unique_memory(krb5_context context,
581
                TALLOC_CTX *mem_ctx,
582
                char **ccache_name,
583
                krb5_ccache *id);
584
585
krb5_error_code smb_krb5_cc_copy_creds(krb5_context context,
586
               krb5_ccache incc, krb5_ccache outcc);
587
588
#endif /* HAVE_KRB5 */
589
590
int ads_krb5_cli_get_ticket(TALLOC_CTX *mem_ctx,
591
          const char *principal,
592
          time_t time_offset,
593
          DATA_BLOB *ticket,
594
          DATA_BLOB *session_key_krb5,
595
          uint32_t extra_ap_opts, const char *ccname,
596
          time_t *tgs_expire,
597
          const char *impersonate_princ_s);
598
599
NTSTATUS krb5_to_nt_status(krb5_error_code kerberos_error);
600
krb5_error_code nt_status_to_krb5(NTSTATUS nt_status);
601
602
#endif /* _KRB5_SAMBA_H */