Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/kdb.h @ 69:33d812a61356
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 17:55:14 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 69:33d812a61356 |
---|---|
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | |
2 /* | |
3 * Copyright 1990, 1991, 2016 by the Massachusetts Institute of Technology. | |
4 * All Rights Reserved. | |
5 * | |
6 * Export of this software from the United States of America may | |
7 * require a specific license from the United States Government. | |
8 * It is the responsibility of any person or organization contemplating | |
9 * export to obtain such a license before exporting. | |
10 * | |
11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and | |
12 * distribute this software and its documentation for any purpose and | |
13 * without fee is hereby granted, provided that the above copyright | |
14 * notice appear in all copies and that both that copyright notice and | |
15 * this permission notice appear in supporting documentation, and that | |
16 * the name of M.I.T. not be used in advertising or publicity pertaining | |
17 * to distribution of the software without specific, written prior | |
18 * permission. Furthermore if you modify this software you must label | |
19 * your software as modified software and not distribute it in such a | |
20 * fashion that it might be confused with the original M.I.T. software. | |
21 * M.I.T. makes no representations about the suitability of | |
22 * this software for any purpose. It is provided "as is" without express | |
23 * or implied warranty. | |
24 */ | |
25 /* | |
26 * Copyright (C) 1998 by the FundsXpress, INC. | |
27 * | |
28 * All rights reserved. | |
29 * | |
30 * Export of this software from the United States of America may require | |
31 * a specific license from the United States Government. It is the | |
32 * responsibility of any person or organization contemplating export to | |
33 * obtain such a license before exporting. | |
34 * | |
35 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and | |
36 * distribute this software and its documentation for any purpose and | |
37 * without fee is hereby granted, provided that the above copyright | |
38 * notice appear in all copies and that both that copyright notice and | |
39 * this permission notice appear in supporting documentation, and that | |
40 * the name of FundsXpress. not be used in advertising or publicity pertaining | |
41 * to distribution of the software without specific, written prior | |
42 * permission. FundsXpress makes no representations about the suitability of | |
43 * this software for any purpose. It is provided "as is" without express | |
44 * or implied warranty. | |
45 * | |
46 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
47 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
48 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
49 */ | |
50 /* | |
51 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. | |
52 * Use is subject to license terms. | |
53 */ | |
54 | |
55 /* KDC Database interface definitions */ | |
56 | |
57 /* This API is not considered as stable as the main krb5 API. | |
58 * | |
59 * - We may make arbitrary incompatible changes between feature | |
60 * releases (e.g. from 1.7 to 1.8). | |
61 * - We will make some effort to avoid making incompatible changes for | |
62 * bugfix releases, but will make them if necessary. | |
63 */ | |
64 | |
65 #ifndef KRB5_KDB5__ | |
66 #define KRB5_KDB5__ | |
67 | |
68 #include <krb5.h> | |
69 | |
70 /* This version will be incremented when incompatible changes are made to the | |
71 * KDB API, and will be kept in sync with the libkdb major version. */ | |
72 #define KRB5_KDB_API_VERSION 10 | |
73 | |
74 /* Salt types */ | |
75 #define KRB5_KDB_SALTTYPE_NORMAL 0 | |
76 /* #define KRB5_KDB_SALTTYPE_V4 1 */ | |
77 #define KRB5_KDB_SALTTYPE_NOREALM 2 | |
78 #define KRB5_KDB_SALTTYPE_ONLYREALM 3 | |
79 #define KRB5_KDB_SALTTYPE_SPECIAL 4 | |
80 /* #define KRB5_KDB_SALTTYPE_AFS3 5 */ | |
81 #define KRB5_KDB_SALTTYPE_CERTHASH 6 | |
82 | |
83 /* Attributes */ | |
84 #define KRB5_KDB_DISALLOW_POSTDATED 0x00000001 | |
85 #define KRB5_KDB_DISALLOW_FORWARDABLE 0x00000002 | |
86 #define KRB5_KDB_DISALLOW_TGT_BASED 0x00000004 | |
87 #define KRB5_KDB_DISALLOW_RENEWABLE 0x00000008 | |
88 #define KRB5_KDB_DISALLOW_PROXIABLE 0x00000010 | |
89 #define KRB5_KDB_DISALLOW_DUP_SKEY 0x00000020 | |
90 #define KRB5_KDB_DISALLOW_ALL_TIX 0x00000040 | |
91 #define KRB5_KDB_REQUIRES_PRE_AUTH 0x00000080 | |
92 #define KRB5_KDB_REQUIRES_HW_AUTH 0x00000100 | |
93 #define KRB5_KDB_REQUIRES_PWCHANGE 0x00000200 | |
94 #define KRB5_KDB_DISALLOW_SVR 0x00001000 | |
95 #define KRB5_KDB_PWCHANGE_SERVICE 0x00002000 | |
96 #define KRB5_KDB_SUPPORT_DESMD5 0x00004000 | |
97 #define KRB5_KDB_NEW_PRINC 0x00008000 | |
98 #define KRB5_KDB_OK_AS_DELEGATE 0x00100000 | |
99 #define KRB5_KDB_OK_TO_AUTH_AS_DELEGATE 0x00200000 /* S4U2Self OK */ | |
100 #define KRB5_KDB_NO_AUTH_DATA_REQUIRED 0x00400000 | |
101 #define KRB5_KDB_LOCKDOWN_KEYS 0x00800000 | |
102 | |
103 /* Creation flags */ | |
104 #define KRB5_KDB_CREATE_BTREE 0x00000001 | |
105 #define KRB5_KDB_CREATE_HASH 0x00000002 | |
106 | |
107 /* Entry get flags */ | |
108 /* Okay to generate a referral on lookup */ | |
109 #define KRB5_KDB_FLAG_REFERRAL_OK 0x00000010 | |
110 /* Client principal lookup (client referrals only) */ | |
111 #define KRB5_KDB_FLAG_CLIENT 0x00000040 | |
112 /* Map cross-realm principals */ | |
113 #define KRB5_KDB_FLAG_MAP_PRINCIPALS 0x00000080 | |
114 /* Protocol transition */ | |
115 #define KRB5_KDB_FLAG_PROTOCOL_TRANSITION 0x00000100 | |
116 /* Constrained delegation */ | |
117 #define KRB5_KDB_FLAG_CONSTRAINED_DELEGATION 0x00000200 | |
118 /* User-to-user */ | |
119 #define KRB5_KDB_FLAG_USER_TO_USER 0x00000800 | |
120 /* Cross-realm */ | |
121 #define KRB5_KDB_FLAG_CROSS_REALM 0x00001000 | |
122 /* Issuing referral */ | |
123 #define KRB5_KDB_FLAG_ISSUING_REFERRAL 0x00004000 | |
124 | |
125 | |
126 #define KRB5_KDB_FLAGS_S4U ( KRB5_KDB_FLAG_PROTOCOL_TRANSITION | \ | |
127 KRB5_KDB_FLAG_CONSTRAINED_DELEGATION ) | |
128 | |
129 /* KDB iteration flags */ | |
130 #define KRB5_DB_ITER_WRITE 0x00000001 | |
131 #define KRB5_DB_ITER_REV 0x00000002 | |
132 #define KRB5_DB_ITER_RECURSE 0x00000004 | |
133 | |
134 /* String attribute names recognized by krb5 */ | |
135 #define KRB5_KDB_SK_SESSION_ENCTYPES "session_enctypes" | |
136 #define KRB5_KDB_SK_REQUIRE_AUTH "require_auth" | |
137 | |
138 #if !defined(_WIN32) | |
139 | |
140 /* | |
141 * Note --- these structures cannot be modified without changing the | |
142 * database version number in libkdb.a, but should be expandable by | |
143 * adding new tl_data types. | |
144 */ | |
145 typedef struct _krb5_tl_data { | |
146 struct _krb5_tl_data* tl_data_next; /* NOT saved */ | |
147 krb5_int16 tl_data_type; | |
148 krb5_ui_2 tl_data_length; | |
149 krb5_octet * tl_data_contents; | |
150 } krb5_tl_data; | |
151 | |
152 /* String attributes (currently stored inside tl-data) map C string keys to | |
153 * values. They can be set via kadmin and consumed by KDC plugins. */ | |
154 typedef struct krb5_string_attr_st { | |
155 char *key; | |
156 char *value; | |
157 } krb5_string_attr; | |
158 | |
159 /* | |
160 * If this ever changes up the version number and make the arrays be as | |
161 * big as necessary. | |
162 * | |
163 * Currently the first type is the enctype and the second is the salt type. | |
164 */ | |
165 typedef struct _krb5_key_data { | |
166 krb5_int16 key_data_ver; /* Version */ | |
167 krb5_ui_2 key_data_kvno; /* Key Version */ | |
168 krb5_int16 key_data_type[2]; /* Array of types */ | |
169 krb5_ui_2 key_data_length[2]; /* Array of lengths */ | |
170 krb5_octet * key_data_contents[2]; /* Array of pointers */ | |
171 } krb5_key_data; | |
172 | |
173 #define KRB5_KDB_V1_KEY_DATA_ARRAY 2 /* # of array elements */ | |
174 | |
175 typedef struct _krb5_keysalt { | |
176 krb5_int16 type; | |
177 krb5_data data; /* Length, data */ | |
178 } krb5_keysalt; | |
179 | |
180 /* | |
181 * A principal database entry. Extensions to this structure currently use the | |
182 * tl_data list. The e_data and e_length fields are not used by any calling | |
183 * code except kdb5_util dump and load, which marshal and unmarshal the array | |
184 * in the dump record. KDB modules may use these fields internally as long as | |
185 * they set e_length appropriately (non-zero if the data should be marshalled | |
186 * across dump and load, zero if not) and handle null e_data values in | |
187 * caller-constructed principal entries. | |
188 */ | |
189 typedef struct _krb5_db_entry_new { | |
190 krb5_magic magic; /* NOT saved */ | |
191 krb5_ui_2 len; | |
192 krb5_ui_4 mask; /* members currently changed/set */ | |
193 krb5_flags attributes; | |
194 krb5_deltat max_life; | |
195 krb5_deltat max_renewable_life; | |
196 krb5_timestamp expiration; /* When the client expires */ | |
197 krb5_timestamp pw_expiration; /* When its passwd expires */ | |
198 krb5_timestamp last_success; /* Last successful passwd */ | |
199 krb5_timestamp last_failed; /* Last failed passwd attempt */ | |
200 krb5_kvno fail_auth_count; /* # of failed passwd attempt */ | |
201 krb5_int16 n_tl_data; | |
202 krb5_int16 n_key_data; | |
203 krb5_ui_2 e_length; /* Length of extra data */ | |
204 krb5_octet * e_data; /* Extra data to be saved */ | |
205 | |
206 krb5_principal princ; /* Length, data */ | |
207 krb5_tl_data * tl_data; /* Linked list */ | |
208 | |
209 /* key_data must be sorted by kvno in descending order. */ | |
210 krb5_key_data * key_data; /* Array */ | |
211 } krb5_db_entry; | |
212 | |
213 typedef struct _osa_policy_ent_t { | |
214 int version; | |
215 char *name; | |
216 krb5_ui_4 pw_min_life; | |
217 krb5_ui_4 pw_max_life; | |
218 krb5_ui_4 pw_min_length; | |
219 krb5_ui_4 pw_min_classes; | |
220 krb5_ui_4 pw_history_num; | |
221 krb5_ui_4 policy_refcnt; /* no longer used */ | |
222 /* Only valid if version > 1 */ | |
223 krb5_ui_4 pw_max_fail; /* pwdMaxFailure */ | |
224 krb5_ui_4 pw_failcnt_interval; /* pwdFailureCountInterval */ | |
225 krb5_ui_4 pw_lockout_duration; /* pwdLockoutDuration */ | |
226 /* Only valid if version > 2 */ | |
227 krb5_ui_4 attributes; | |
228 krb5_ui_4 max_life; | |
229 krb5_ui_4 max_renewable_life; | |
230 char * allowed_keysalts; | |
231 krb5_int16 n_tl_data; | |
232 krb5_tl_data * tl_data; | |
233 } osa_policy_ent_rec, *osa_policy_ent_t; | |
234 | |
235 typedef void (*osa_adb_iter_policy_func) (void *, osa_policy_ent_t); | |
236 | |
237 typedef struct __krb5_key_salt_tuple { | |
238 krb5_enctype ks_enctype; | |
239 krb5_int32 ks_salttype; | |
240 } krb5_key_salt_tuple; | |
241 | |
242 #define KRB5_KDB_MAGIC_NUMBER 0xdbdbdbdb | |
243 #define KRB5_KDB_V1_BASE_LENGTH 38 | |
244 | |
245 #define KRB5_KDB_MAX_ALLOWED_KS_LEN 512 | |
246 | |
247 #define KRB5_TL_LAST_PWD_CHANGE 0x0001 | |
248 #define KRB5_TL_MOD_PRINC 0x0002 | |
249 #define KRB5_TL_KADM_DATA 0x0003 | |
250 #define KRB5_TL_KADM5_E_DATA 0x0004 | |
251 #define KRB5_TL_RB1_CHALLENGE 0x0005 | |
252 #ifdef SECURID | |
253 #define KRB5_TL_SECURID_STATE 0x0006 | |
254 #endif /* SECURID */ | |
255 #define KRB5_TL_USER_CERTIFICATE 0x0007 | |
256 #define KRB5_TL_MKVNO 0x0008 | |
257 #define KRB5_TL_ACTKVNO 0x0009 | |
258 #define KRB5_TL_MKEY_AUX 0x000a | |
259 | |
260 /* String attributes may not always be represented in tl-data. kadmin clients | |
261 * must use the get_strings and set_string RPCs. */ | |
262 #define KRB5_TL_STRING_ATTRS 0x000b | |
263 | |
264 #define KRB5_TL_PAC_LOGON_INFO 0x0100 /* NDR encoded validation info */ | |
265 #define KRB5_TL_SERVER_REFERRAL 0x0200 /* ASN.1 encoded ServerReferralInfo */ | |
266 #define KRB5_TL_SVR_REFERRAL_DATA 0x0300 /* ASN.1 encoded PA-SVR-REFERRAL-DATA */ | |
267 #define KRB5_TL_CONSTRAINED_DELEGATION_ACL 0x0400 /* Each entry is a permitted SPN */ | |
268 #define KRB5_TL_LM_KEY 0x0500 /* LM OWF */ | |
269 #define KRB5_TL_X509_SUBJECT_ISSUER_NAME 0x0600 /* <I>IssuerDN<S>SubjectDN */ | |
270 #define KRB5_TL_LAST_ADMIN_UNLOCK 0x0700 /* Timestamp of admin unlock */ | |
271 | |
272 #define KRB5_TL_DB_ARGS 0x7fff | |
273 | |
274 /* version number for KRB5_TL_ACTKVNO data */ | |
275 #define KRB5_TL_ACTKVNO_VER 1 | |
276 | |
277 /* version number for KRB5_TL_MKEY_AUX data */ | |
278 #define KRB5_TL_MKEY_AUX_VER 1 | |
279 | |
280 typedef struct _krb5_actkvno_node { | |
281 struct _krb5_actkvno_node *next; | |
282 krb5_kvno act_kvno; | |
283 krb5_timestamp act_time; | |
284 } krb5_actkvno_node; | |
285 | |
286 typedef struct _krb5_mkey_aux_node { | |
287 struct _krb5_mkey_aux_node *next; | |
288 krb5_kvno mkey_kvno; /* kvno of mkey protecting the latest_mkey */ | |
289 krb5_key_data latest_mkey; /* most recent mkey */ | |
290 } krb5_mkey_aux_node; | |
291 | |
292 typedef struct _krb5_keylist_node { | |
293 krb5_keyblock keyblock; | |
294 krb5_kvno kvno; | |
295 struct _krb5_keylist_node *next; | |
296 } krb5_keylist_node; | |
297 | |
298 /* | |
299 * Determines the number of failed KDC requests before DISALLOW_ALL_TIX is set | |
300 * on the principal. | |
301 */ | |
302 #define KRB5_MAX_FAIL_COUNT 5 | |
303 | |
304 /* XXX depends on knowledge of krb5_parse_name() formats */ | |
305 #define KRB5_KDB_M_NAME "K/M" /* Kerberos/Master */ | |
306 | |
307 /* prompts used by default when reading the KDC password from the keyboard. */ | |
308 #define KRB5_KDC_MKEY_1 "Enter KDC database master key" | |
309 #define KRB5_KDC_MKEY_2 "Re-enter KDC database master key to verify" | |
310 | |
311 | |
312 extern char *krb5_mkey_pwd_prompt1; | |
313 extern char *krb5_mkey_pwd_prompt2; | |
314 | |
315 /* | |
316 * These macros specify the encoding of data within the database. | |
317 * | |
318 * Data encoding is little-endian. | |
319 */ | |
320 #ifdef _KRB5_INT_H | |
321 #include "k5-platform.h" | |
322 #define krb5_kdb_decode_int16(cp, i16) \ | |
323 *((krb5_int16 *) &(i16)) = load_16_le(cp) | |
324 #define krb5_kdb_decode_int32(cp, i32) \ | |
325 *((krb5_int32 *) &(i32)) = load_32_le(cp) | |
326 #define krb5_kdb_encode_int16(i16, cp) store_16_le(i16, cp) | |
327 #define krb5_kdb_encode_int32(i32, cp) store_32_le(i32, cp) | |
328 #endif /* _KRB5_INT_H */ | |
329 | |
330 #define KRB5_KDB_OPEN_RW 0 | |
331 #define KRB5_KDB_OPEN_RO 1 | |
332 | |
333 #ifndef KRB5_KDB_SRV_TYPE_KDC | |
334 #define KRB5_KDB_SRV_TYPE_KDC 0x0100 | |
335 #endif | |
336 | |
337 #ifndef KRB5_KDB_SRV_TYPE_ADMIN | |
338 #define KRB5_KDB_SRV_TYPE_ADMIN 0x0200 | |
339 #endif | |
340 | |
341 /* 0x0300 was KRB5_KDB_SRV_TYPE_PASSWD but it is no longer used. */ | |
342 | |
343 #ifndef KRB5_KDB_SRV_TYPE_OTHER | |
344 #define KRB5_KDB_SRV_TYPE_OTHER 0x0400 | |
345 #endif | |
346 | |
347 #define KRB5_KDB_OPT_SET_DB_NAME 0 | |
348 #define KRB5_KDB_OPT_SET_LOCK_MODE 1 | |
349 | |
350 #define KRB5_DB_LOCKMODE_SHARED 0x0001 | |
351 #define KRB5_DB_LOCKMODE_EXCLUSIVE 0x0002 | |
352 #define KRB5_DB_LOCKMODE_PERMANENT 0x0008 | |
353 | |
354 /* libkdb.spec */ | |
355 krb5_error_code krb5_db_setup_lib_handle(krb5_context kcontext); | |
356 krb5_error_code krb5_db_open( krb5_context kcontext, char **db_args, int mode ); | |
357 krb5_error_code krb5_db_init ( krb5_context kcontext ); | |
358 krb5_error_code krb5_db_create ( krb5_context kcontext, char **db_args ); | |
359 krb5_error_code krb5_db_inited ( krb5_context kcontext ); | |
360 krb5_error_code kdb5_db_create ( krb5_context kcontext, char **db_args ); | |
361 krb5_error_code krb5_db_fini ( krb5_context kcontext ); | |
362 const char * krb5_db_errcode2string ( krb5_context kcontext, long err_code ); | |
363 krb5_error_code krb5_db_destroy ( krb5_context kcontext, char **db_args ); | |
364 krb5_error_code krb5_db_promote ( krb5_context kcontext, char **db_args ); | |
365 krb5_error_code krb5_db_get_age ( krb5_context kcontext, char *db_name, time_t *t ); | |
366 krb5_error_code krb5_db_lock ( krb5_context kcontext, int lock_mode ); | |
367 krb5_error_code krb5_db_unlock ( krb5_context kcontext ); | |
368 krb5_error_code krb5_db_get_principal ( krb5_context kcontext, | |
369 krb5_const_principal search_for, | |
370 unsigned int flags, | |
371 krb5_db_entry **entry ); | |
372 void krb5_db_free_principal ( krb5_context kcontext, krb5_db_entry *entry ); | |
373 krb5_error_code krb5_db_put_principal ( krb5_context kcontext, | |
374 krb5_db_entry *entry ); | |
375 krb5_error_code krb5_db_delete_principal ( krb5_context kcontext, | |
376 krb5_principal search_for ); | |
377 krb5_error_code krb5_db_rename_principal ( krb5_context kcontext, | |
378 krb5_principal source, | |
379 krb5_principal target ); | |
380 | |
381 /* | |
382 * Iterate over principals in the KDB. If the callback may write to the DB, | |
383 * the caller must get an exclusive lock with krb5_db_lock before iterating, | |
384 * and release it with krb5_db_unlock after iterating. | |
385 */ | |
386 krb5_error_code krb5_db_iterate ( krb5_context kcontext, | |
387 char *match_entry, | |
388 int (*func) (krb5_pointer, krb5_db_entry *), | |
389 krb5_pointer func_arg, krb5_flags iterflags ); | |
390 | |
391 | |
392 krb5_error_code krb5_db_store_master_key ( krb5_context kcontext, | |
393 char *keyfile, | |
394 krb5_principal mname, | |
395 krb5_kvno kvno, | |
396 krb5_keyblock *key, | |
397 char *master_pwd); | |
398 krb5_error_code krb5_db_store_master_key_list ( krb5_context kcontext, | |
399 char *keyfile, | |
400 krb5_principal mname, | |
401 char *master_pwd); | |
402 krb5_error_code krb5_db_fetch_mkey ( krb5_context context, | |
403 krb5_principal mname, | |
404 krb5_enctype etype, | |
405 krb5_boolean fromkeyboard, | |
406 krb5_boolean twice, | |
407 char *db_args, | |
408 krb5_kvno *kvno, | |
409 krb5_data *salt, | |
410 krb5_keyblock *key); | |
411 krb5_error_code | |
412 krb5_db_fetch_mkey_list( krb5_context context, | |
413 krb5_principal mname, | |
414 const krb5_keyblock * mkey ); | |
415 | |
416 krb5_error_code | |
417 krb5_dbe_find_enctype( krb5_context kcontext, | |
418 krb5_db_entry *dbentp, | |
419 krb5_int32 ktype, | |
420 krb5_int32 stype, | |
421 krb5_int32 kvno, | |
422 krb5_key_data **kdatap); | |
423 | |
424 | |
425 krb5_error_code krb5_dbe_search_enctype ( krb5_context kcontext, | |
426 krb5_db_entry *dbentp, | |
427 krb5_int32 *start, | |
428 krb5_int32 ktype, | |
429 krb5_int32 stype, | |
430 krb5_int32 kvno, | |
431 krb5_key_data **kdatap); | |
432 | |
433 krb5_error_code | |
434 krb5_db_setup_mkey_name ( krb5_context context, | |
435 const char *keyname, | |
436 const char *realm, | |
437 char **fullname, | |
438 krb5_principal *principal); | |
439 | |
440 /** | |
441 * Decrypts the key given in @@a key_data. If @a mkey is specified, that | |
442 * master key is used. If @a mkey is NULL, then all master keys are tried. | |
443 */ | |
444 krb5_error_code | |
445 krb5_dbe_decrypt_key_data( krb5_context context, | |
446 const krb5_keyblock * mkey, | |
447 const krb5_key_data * key_data, | |
448 krb5_keyblock * dbkey, | |
449 krb5_keysalt * keysalt); | |
450 | |
451 krb5_error_code | |
452 krb5_dbe_encrypt_key_data( krb5_context context, | |
453 const krb5_keyblock * mkey, | |
454 const krb5_keyblock * dbkey, | |
455 const krb5_keysalt * keysalt, | |
456 int keyver, | |
457 krb5_key_data * key_data); | |
458 | |
459 krb5_error_code | |
460 krb5_dbe_fetch_act_key_list(krb5_context context, | |
461 krb5_principal princ, | |
462 krb5_actkvno_node **act_key_list); | |
463 | |
464 krb5_error_code | |
465 krb5_dbe_find_act_mkey( krb5_context context, | |
466 krb5_actkvno_node * act_mkey_list, | |
467 krb5_kvno * act_kvno, | |
468 krb5_keyblock ** act_mkey); | |
469 | |
470 krb5_error_code | |
471 krb5_dbe_find_mkey( krb5_context context, | |
472 krb5_db_entry * entry, | |
473 krb5_keyblock ** mkey); | |
474 | |
475 /* Set *mkvno to mkvno in entry tl_data, or 0 if not present. */ | |
476 krb5_error_code | |
477 krb5_dbe_lookup_mkvno( krb5_context context, | |
478 krb5_db_entry * entry, | |
479 krb5_kvno * mkvno); | |
480 | |
481 krb5_keylist_node * | |
482 krb5_db_mkey_list_alias( krb5_context kcontext ); | |
483 | |
484 /* Set *mkvno to mkvno in entry tl_data, or minimum value from mkey_list. */ | |
485 krb5_error_code | |
486 krb5_dbe_get_mkvno( krb5_context context, | |
487 krb5_db_entry * entry, | |
488 krb5_kvno * mkvno); | |
489 | |
490 krb5_error_code | |
491 krb5_dbe_lookup_mod_princ_data( krb5_context context, | |
492 krb5_db_entry * entry, | |
493 krb5_timestamp * mod_time, | |
494 krb5_principal * mod_princ); | |
495 | |
496 krb5_error_code | |
497 krb5_dbe_lookup_mkey_aux( krb5_context context, | |
498 krb5_db_entry * entry, | |
499 krb5_mkey_aux_node ** mkey_aux_data_list); | |
500 krb5_error_code | |
501 krb5_dbe_update_mkvno( krb5_context context, | |
502 krb5_db_entry * entry, | |
503 krb5_kvno mkvno); | |
504 | |
505 krb5_error_code | |
506 krb5_dbe_lookup_actkvno( krb5_context context, | |
507 krb5_db_entry * entry, | |
508 krb5_actkvno_node ** actkvno_list); | |
509 | |
510 krb5_error_code | |
511 krb5_dbe_update_mkey_aux( krb5_context context, | |
512 krb5_db_entry * entry, | |
513 krb5_mkey_aux_node * mkey_aux_data_list); | |
514 | |
515 krb5_error_code | |
516 krb5_dbe_update_actkvno(krb5_context context, | |
517 krb5_db_entry * entry, | |
518 const krb5_actkvno_node *actkvno_list); | |
519 | |
520 krb5_error_code | |
521 krb5_dbe_update_last_pwd_change( krb5_context context, | |
522 krb5_db_entry * entry, | |
523 krb5_timestamp stamp); | |
524 | |
525 krb5_error_code | |
526 krb5_dbe_update_last_admin_unlock( krb5_context context, | |
527 krb5_db_entry * entry, | |
528 krb5_timestamp stamp); | |
529 | |
530 krb5_error_code | |
531 krb5_dbe_lookup_tl_data( krb5_context context, | |
532 krb5_db_entry * entry, | |
533 krb5_tl_data * ret_tl_data); | |
534 | |
535 krb5_error_code | |
536 krb5_dbe_create_key_data( krb5_context context, | |
537 krb5_db_entry * entry); | |
538 | |
539 | |
540 krb5_error_code | |
541 krb5_dbe_update_mod_princ_data( krb5_context context, | |
542 krb5_db_entry * entry, | |
543 krb5_timestamp mod_date, | |
544 krb5_const_principal mod_princ); | |
545 | |
546 /* | |
547 * These are wrappers around realloc() and free(). Applications and KDB | |
548 * modules can use them when manipulating principal and policy entries to | |
549 * ensure that they allocate and free memory in a manner compatible with the | |
550 * library. Using libkrb5 or libkbd5 functions to construct values (such as | |
551 * krb5_copy_principal() to construct the princ field of a krb5_db_entry) is | |
552 * also safe. On Unix platforms, just using malloc() and free() is safe as | |
553 * long as the application or module does not use a malloc replacement. | |
554 */ | |
555 void *krb5_db_alloc( krb5_context kcontext, | |
556 void *ptr, | |
557 size_t size ); | |
558 void krb5_db_free( krb5_context kcontext, | |
559 void *ptr); | |
560 | |
561 | |
562 krb5_error_code | |
563 krb5_dbe_lookup_last_pwd_change( krb5_context context, | |
564 krb5_db_entry * entry, | |
565 krb5_timestamp * stamp); | |
566 | |
567 krb5_error_code | |
568 krb5_dbe_lookup_last_admin_unlock( krb5_context context, | |
569 krb5_db_entry * entry, | |
570 krb5_timestamp * stamp); | |
571 | |
572 /* Retrieve the set of string attributes in entry, in no particular order. | |
573 * Free *strings_out with krb5_dbe_free_strings when done. */ | |
574 krb5_error_code | |
575 krb5_dbe_get_strings(krb5_context context, krb5_db_entry *entry, | |
576 krb5_string_attr **strings_out, int *count_out); | |
577 | |
578 /* Retrieve a single string attribute from entry, or NULL if there is no | |
579 * attribute for key. Free *value_out with krb5_dbe_free_string when done. */ | |
580 krb5_error_code | |
581 krb5_dbe_get_string(krb5_context context, krb5_db_entry *entry, | |
582 const char *key, char **value_out); | |
583 | |
584 /* Change or add a string attribute in entry, or delete it if value is NULL. */ | |
585 krb5_error_code | |
586 krb5_dbe_set_string(krb5_context context, krb5_db_entry *entry, | |
587 const char *key, const char *value); | |
588 | |
589 krb5_error_code | |
590 krb5_dbe_delete_tl_data( krb5_context context, | |
591 krb5_db_entry * entry, | |
592 krb5_int16 tl_data_type); | |
593 | |
594 krb5_error_code | |
595 krb5_db_update_tl_data(krb5_context context, | |
596 krb5_int16 * n_tl_datap, | |
597 krb5_tl_data **tl_datap, | |
598 krb5_tl_data * new_tl_data); | |
599 | |
600 krb5_error_code | |
601 krb5_dbe_update_tl_data( krb5_context context, | |
602 krb5_db_entry * entry, | |
603 krb5_tl_data * new_tl_data); | |
604 | |
605 /* Compute the salt for a key data entry given the corresponding principal. */ | |
606 krb5_error_code | |
607 krb5_dbe_compute_salt(krb5_context context, const krb5_key_data *key, | |
608 krb5_const_principal princ, krb5_int16 *salttype_out, | |
609 krb5_data **salt_out); | |
610 | |
611 /* | |
612 * Modify the key data of entry to explicitly store salt values using the | |
613 * KRB5_KDB_SALTTYPE_SPECIAL salt type. | |
614 */ | |
615 krb5_error_code | |
616 krb5_dbe_specialize_salt(krb5_context context, krb5_db_entry *entry); | |
617 | |
618 krb5_error_code | |
619 krb5_dbe_cpw( krb5_context kcontext, | |
620 krb5_keyblock * master_key, | |
621 krb5_key_salt_tuple * ks_tuple, | |
622 int ks_tuple_count, | |
623 char * passwd, | |
624 int new_kvno, | |
625 krb5_boolean keepold, | |
626 krb5_db_entry * db_entry); | |
627 | |
628 | |
629 krb5_error_code | |
630 krb5_dbe_ark( krb5_context context, | |
631 krb5_keyblock * master_key, | |
632 krb5_key_salt_tuple * ks_tuple, | |
633 int ks_tuple_count, | |
634 krb5_db_entry * db_entry); | |
635 | |
636 krb5_error_code | |
637 krb5_dbe_crk( krb5_context context, | |
638 krb5_keyblock * master_key, | |
639 krb5_key_salt_tuple * ks_tuple, | |
640 int ks_tuple_count, | |
641 krb5_boolean keepold, | |
642 krb5_db_entry * db_entry); | |
643 | |
644 krb5_error_code | |
645 krb5_dbe_apw( krb5_context context, | |
646 krb5_keyblock * master_key, | |
647 krb5_key_salt_tuple * ks_tuple, | |
648 int ks_tuple_count, | |
649 char * passwd, | |
650 krb5_db_entry * db_entry); | |
651 | |
652 int | |
653 krb5_db_get_key_data_kvno( krb5_context context, | |
654 int count, | |
655 krb5_key_data * data); | |
656 | |
657 krb5_error_code krb5_db_check_transited_realms(krb5_context kcontext, | |
658 const krb5_data *tr_contents, | |
659 const krb5_data *client_realm, | |
660 const krb5_data *server_realm); | |
661 | |
662 krb5_error_code krb5_db_check_policy_as(krb5_context kcontext, | |
663 krb5_kdc_req *request, | |
664 krb5_db_entry *client, | |
665 krb5_db_entry *server, | |
666 krb5_timestamp kdc_time, | |
667 const char **status, | |
668 krb5_pa_data ***e_data); | |
669 | |
670 krb5_error_code krb5_db_check_policy_tgs(krb5_context kcontext, | |
671 krb5_kdc_req *request, | |
672 krb5_db_entry *server, | |
673 krb5_ticket *ticket, | |
674 const char **status, | |
675 krb5_pa_data ***e_data); | |
676 | |
677 void krb5_db_audit_as_req(krb5_context kcontext, krb5_kdc_req *request, | |
678 const krb5_address *local_addr, | |
679 const krb5_address *remote_addr, | |
680 krb5_db_entry *client, krb5_db_entry *server, | |
681 krb5_timestamp authtime, krb5_error_code error_code); | |
682 | |
683 void krb5_db_refresh_config(krb5_context kcontext); | |
684 | |
685 krb5_error_code krb5_db_check_allowed_to_delegate(krb5_context kcontext, | |
686 krb5_const_principal client, | |
687 const krb5_db_entry *server, | |
688 krb5_const_principal proxy); | |
689 | |
690 krb5_error_code krb5_db_get_s4u_x509_principal(krb5_context kcontext, | |
691 const krb5_data *client_cert, | |
692 krb5_const_principal in_princ, | |
693 unsigned int flags, | |
694 krb5_db_entry **entry); | |
695 | |
696 krb5_error_code krb5_db_allowed_to_delegate_from(krb5_context context, | |
697 krb5_const_principal client, | |
698 krb5_const_principal server, | |
699 krb5_pac server_pac, | |
700 const krb5_db_entry *proxy); | |
701 | |
702 /** | |
703 * Sort an array of @a krb5_key_data keys in descending order by their kvno. | |
704 * Key data order within a kvno is preserved. | |
705 * | |
706 * @param key_data | |
707 * The @a krb5_key_data array to sort. This is sorted in place so the | |
708 * array will be modified. | |
709 * @param key_data_length | |
710 * The length of @a key_data. | |
711 */ | |
712 void | |
713 krb5_dbe_sort_key_data(krb5_key_data *key_data, size_t key_data_length); | |
714 | |
715 krb5_error_code | |
716 krb5_db_issue_pac(krb5_context context, unsigned int flags, | |
717 krb5_db_entry *client, krb5_keyblock *replaced_reply_key, | |
718 krb5_db_entry *server, krb5_db_entry *krbtgt, | |
719 krb5_timestamp authtime, krb5_pac old_pac, krb5_pac new_pac, | |
720 krb5_data ***auth_indicators); | |
721 | |
722 /* default functions. Should not be directly called */ | |
723 /* | |
724 * Default functions prototype | |
725 */ | |
726 | |
727 krb5_error_code | |
728 krb5_dbe_def_search_enctype( krb5_context kcontext, | |
729 krb5_db_entry *dbentp, | |
730 krb5_int32 *start, | |
731 krb5_int32 ktype, | |
732 krb5_int32 stype, | |
733 krb5_int32 kvno, | |
734 krb5_key_data **kdatap); | |
735 | |
736 krb5_error_code | |
737 krb5_def_store_mkey_list( krb5_context context, | |
738 char *keyfile, | |
739 krb5_principal mname, | |
740 krb5_keylist_node *keylist, | |
741 char *master_pwd); | |
742 | |
743 krb5_error_code | |
744 krb5_db_def_fetch_mkey( krb5_context context, | |
745 krb5_principal mname, | |
746 krb5_keyblock *key, | |
747 krb5_kvno *kvno, | |
748 char *db_args); | |
749 | |
750 krb5_error_code | |
751 krb5_def_fetch_mkey_list( krb5_context context, | |
752 krb5_principal mprinc, | |
753 const krb5_keyblock *mkey, | |
754 krb5_keylist_node **mkeys_list); | |
755 | |
756 krb5_error_code | |
757 krb5_dbe_def_cpw( krb5_context context, | |
758 krb5_keyblock * master_key, | |
759 krb5_key_salt_tuple * ks_tuple, | |
760 int ks_tuple_count, | |
761 char * passwd, | |
762 int new_kvno, | |
763 krb5_boolean keepold, | |
764 krb5_db_entry * db_entry); | |
765 | |
766 krb5_error_code | |
767 krb5_dbe_def_decrypt_key_data( krb5_context context, | |
768 const krb5_keyblock * mkey, | |
769 const krb5_key_data * key_data, | |
770 krb5_keyblock * dbkey, | |
771 krb5_keysalt * keysalt); | |
772 | |
773 krb5_error_code | |
774 krb5_dbe_def_encrypt_key_data( krb5_context context, | |
775 const krb5_keyblock * mkey, | |
776 const krb5_keyblock * dbkey, | |
777 const krb5_keysalt * keysalt, | |
778 int keyver, | |
779 krb5_key_data * key_data); | |
780 | |
781 krb5_error_code | |
782 krb5_db_def_rename_principal( krb5_context kcontext, | |
783 krb5_const_principal source, | |
784 krb5_const_principal target); | |
785 | |
786 krb5_error_code | |
787 krb5_db_create_policy( krb5_context kcontext, | |
788 osa_policy_ent_t policy); | |
789 | |
790 krb5_error_code | |
791 krb5_db_get_policy ( krb5_context kcontext, | |
792 char *name, | |
793 osa_policy_ent_t *policy ); | |
794 | |
795 krb5_error_code | |
796 krb5_db_put_policy( krb5_context kcontext, | |
797 osa_policy_ent_t policy); | |
798 | |
799 krb5_error_code | |
800 krb5_db_iter_policy( krb5_context kcontext, | |
801 char *match_entry, | |
802 osa_adb_iter_policy_func func, | |
803 void *data); | |
804 | |
805 krb5_error_code | |
806 krb5_db_delete_policy( krb5_context kcontext, | |
807 char *policy); | |
808 | |
809 void | |
810 krb5_db_free_policy( krb5_context kcontext, | |
811 osa_policy_ent_t policy); | |
812 | |
813 | |
814 krb5_error_code | |
815 krb5_db_set_context(krb5_context, void *db_context); | |
816 | |
817 krb5_error_code | |
818 krb5_db_get_context(krb5_context, void **db_context); | |
819 | |
820 void | |
821 krb5_dbe_free_key_data_contents(krb5_context, krb5_key_data *); | |
822 | |
823 void | |
824 krb5_dbe_free_key_list(krb5_context, krb5_keylist_node *); | |
825 | |
826 void | |
827 krb5_dbe_free_actkvno_list(krb5_context, krb5_actkvno_node *); | |
828 | |
829 void | |
830 krb5_dbe_free_mkey_aux_list(krb5_context, krb5_mkey_aux_node *); | |
831 | |
832 void | |
833 krb5_dbe_free_tl_data(krb5_context, krb5_tl_data *); | |
834 | |
835 void | |
836 krb5_dbe_free_strings(krb5_context, krb5_string_attr *, int count); | |
837 | |
838 void | |
839 krb5_dbe_free_string(krb5_context, char *); | |
840 | |
841 /* | |
842 * Register the KDB keytab type, allowing "KDB:" to be used as a keytab name. | |
843 * For this type to work, the context used for keytab operations must have an | |
844 * associated database handle (via krb5_db_open()). | |
845 */ | |
846 krb5_error_code krb5_db_register_keytab(krb5_context context); | |
847 | |
848 #define KRB5_KDB_DEF_FLAGS 0 | |
849 | |
850 #define KDB_MAX_DB_NAME 128 | |
851 #define KDB_REALM_SECTION "realms" | |
852 #define KDB_MODULE_POINTER "database_module" | |
853 #define KDB_MODULE_DEF_SECTION "dbdefaults" | |
854 #define KDB_MODULE_SECTION "dbmodules" | |
855 #define KDB_LIB_POINTER "db_library" | |
856 #define KDB_DATABASE_CONF_FILE DEFAULT_SECURE_PROFILE_PATH | |
857 #define KDB_DATABASE_ENV_PROF KDC_PROFILE_ENV | |
858 | |
859 #define KRB5_KDB_OPEN_RW 0 | |
860 #define KRB5_KDB_OPEN_RO 1 | |
861 | |
862 #define KRB5_KDB_OPT_SET_DB_NAME 0 | |
863 #define KRB5_KDB_OPT_SET_LOCK_MODE 1 | |
864 | |
865 /* | |
866 * This number indicates the date of the last incompatible change to the DAL. | |
867 * The maj_ver field of the module's vtable structure must match this version. | |
868 */ | |
869 #define KRB5_KDB_DAL_MAJOR_VERSION 9 | |
870 | |
871 /* | |
872 * Note the following when converting a module to DAL version 9: | |
873 * | |
874 * - get_authdata_info() and sign_authdata() have been removed, and issue_pac() | |
875 * has been added. | |
876 * | |
877 * - check_allowed_to_delegate() must handle a null proxy argument, returning | |
878 * success if server has any authorized delegation targets in the traditional | |
879 * scheme. | |
880 * | |
881 * - allowed_to_delegate_from() accepts a krb5_pac parameter (in place | |
882 * server_ad_info) for the impersonator's PAC. | |
883 * | |
884 * - check_allowed_to_delegate() and allowed_to_delegate_from() must return | |
885 * KRB5KDC_ERR_BADOPTION on authorization failure. | |
886 * | |
887 * - the KRB5_KDB_FLAG_ISSUE_PAC and KRB5_FLAG_CLIENT_REFERRALS_ONLY flags have | |
888 * been combined into KRB5_KDB_FLAG_CLIENT. | |
889 * | |
890 * - the KRB5_KDB_FLAG_CANONICALIZE flag has been renamed to | |
891 * KRB5_KDB_FLAG_REFERRAL_OK, and is only passed to get_principal() when a | |
892 * realm referral is allowed (AS client and TGS server lookups, when the | |
893 * CANONICALIZE option is requested or, for AS requests, when the client is | |
894 * an enterprise principal). As of DAL version 8 the KDB module should | |
895 * always canonicalize aliases within a realm; the KDC will decide whether to | |
896 * use the original or canonical principal. | |
897 */ | |
898 | |
899 /* | |
900 * A krb5_context can hold one database object. Modules should use | |
901 * krb5_db_set_context and krb5_db_get_context to store state associated with | |
902 * the database object. | |
903 * | |
904 * Some module functions are mandatory for KDC operation; others are optional | |
905 * or apply only to administrative operations. If a function is optional, a | |
906 * module can leave the function pointer as NULL. Alternatively, modules can | |
907 * return KRB5_PLUGIN_OP_NOTSUPP when asked to perform an inapplicable action. | |
908 * | |
909 * Some module functions have default implementations which will call back into | |
910 * the vtable interface. Leave these functions as NULL to use the default | |
911 * implementations. | |
912 * | |
913 * The documentation in these comments describes the DAL as it is currently | |
914 * implemented and used, not as it should be. So if anything seems off, that | |
915 * probably means the current state of things is off. | |
916 * | |
917 * Modules must allocate memory for principal entries, policy entries, and | |
918 * other structures using an allocator compatible with malloc() as seen by | |
919 * libkdb5 and libkrb5. Modules may link against libkdb5 and call | |
920 * krb5_db_alloc() to be certain that the same malloc implementation is used. | |
921 */ | |
922 | |
923 typedef struct _kdb_vftabl { | |
924 short int maj_ver; | |
925 short int min_ver; | |
926 | |
927 /* | |
928 * Mandatory: Invoked after the module library is loaded, when the first DB | |
929 * using the module is opened, across all contexts. | |
930 */ | |
931 krb5_error_code (*init_library)(void); | |
932 | |
933 /* | |
934 * Mandatory: Invoked before the module library is unloaded, after the last | |
935 * DB using the module is closed, across all contexts. | |
936 */ | |
937 krb5_error_code (*fini_library)(void); | |
938 | |
939 /* | |
940 * Mandatory: Initialize a database object. Profile settings should be | |
941 * read from conf_section inside KDB_MODULE_SECTION. db_args communicates | |
942 * command-line arguments for module-specific flags. mode will be one of | |
943 * KRB5_KDB_OPEN_{RW,RO} or'd with one of | |
944 * KRB5_KDB_SRV_TYPE_{KDC,ADMIN,PASSWD,OTHER}. | |
945 */ | |
946 krb5_error_code (*init_module)(krb5_context kcontext, char *conf_section, | |
947 char **db_args, int mode); | |
948 | |
949 /* | |
950 * Mandatory: Finalize the database object contained in a context. Free | |
951 * any state contained in the db_context pointer and null it out. | |
952 */ | |
953 krb5_error_code (*fini_module)(krb5_context kcontext); | |
954 | |
955 /* | |
956 * Optional: Initialize a database object while creating the underlying | |
957 * database. conf_section and db_args have the same meaning as in | |
958 * init_module. This function may return an error if the database already | |
959 * exists. Used by kdb5_util create. | |
960 * | |
961 * If db_args contains the value "temporary", the module should create an | |
962 * exclusively locked side copy of the database suitable for loading in a | |
963 * propagation from primary to replica. This side copy will later be | |
964 * promoted with promote_db, allowing complete updates of the DB with no | |
965 * loss in read availability. If the module cannot comply with this | |
966 * architecture, it should return an error. | |
967 */ | |
968 krb5_error_code (*create)(krb5_context kcontext, char *conf_section, | |
969 char **db_args); | |
970 | |
971 /* | |
972 * Optional: Destroy a database. conf_section and db_args have the same | |
973 * meaning as in init_module. Used by kdb5_util destroy. In current | |
974 * usage, the database is destroyed while open, so the module should handle | |
975 * that. | |
976 */ | |
977 krb5_error_code (*destroy)(krb5_context kcontext, char *conf_section, | |
978 char **db_args); | |
979 | |
980 /* | |
981 * Deprecated: No longer used as of krb5 1.10; can be removed in the next | |
982 * DAL revision. Modules should leave as NULL. | |
983 */ | |
984 krb5_error_code (*get_age)(krb5_context kcontext, char *db_name, | |
985 time_t *age); | |
986 | |
987 /* | |
988 * Optional: Lock the database, with semantics depending on the mode | |
989 * argument: | |
990 * | |
991 * KRB5_DB_LOCKMODE_SHARED: Lock may coexist with other shared locks. | |
992 * KRB5_DB_LOCKMODE_EXCLUSIVE: Lock may not coexist with other locks. | |
993 * KRB5_DB_LOCKMODE_PERMANENT: Exclusive lock surviving process exit. | |
994 * | |
995 * Used by the "kadmin lock" command, incremental propagation, and | |
996 * kdb5_util dump. Incremental propagation support requires shared locks | |
997 * to operate. kdb5_util dump will continue unlocked if the module returns | |
998 * KRB5_PLUGIN_OP_NOTSUPP. | |
999 */ | |
1000 krb5_error_code (*lock)(krb5_context kcontext, int mode); | |
1001 | |
1002 /* Optional: Release a lock created with db_lock. */ | |
1003 krb5_error_code (*unlock)(krb5_context kcontext); | |
1004 | |
1005 /* | |
1006 * Mandatory: Set *entry to an allocated entry for the principal | |
1007 * search_for. If the principal is not found, return KRB5_KDB_NOENTRY. | |
1008 * | |
1009 * The meaning of flags are as follows: | |
1010 * | |
1011 * KRB5_KDB_FLAG_REFERRAL_OK: Set by the KDC when looking up entries for an | |
1012 * AS client with canonicalization requested or for an enterprise | |
1013 * principal, or for a TGS request server with canonicalization | |
1014 * requested. Determines whether the module should return out-of-realm | |
1015 * referrals. | |
1016 * | |
1017 * KRB5_KDB_FLAG_CLIENT: Set by the KDC when looking up a client principal | |
1018 * during an AS or TGS request. Affects how the module should return | |
1019 * out-of-realm referrals. | |
1020 * | |
1021 * KRB5_KDB_FLAG_MAP_PRINCIPALS: Set by the KDC when looking up the client | |
1022 * entry during TGS requests, except for S4U TGS requests and requests | |
1023 * where the server entry has the KRB5_KDB_NO_AUTH_DATA_REQUIRED | |
1024 * attribute. Indicates that the module should map foreign principals | |
1025 * to local principals if it supports doing so. | |
1026 * | |
1027 * KRB5_KDB_FLAG_PROTOCOL_TRANSITION: Set by the KDC when looking up the | |
1028 * client entry during an S4U2Self TGS request. This affects the PAC | |
1029 * information which should be included when authorization data is | |
1030 * generated; see the Microsoft S4U specification for details. | |
1031 * | |
1032 * KRB5_KDB_FLAG_CONSTRAINED_DELEGATION: Set by the KDC when looking up the | |
1033 * client entry during an S4U2Proxy TGS request. Also affects PAC | |
1034 * generation. | |
1035 * | |
1036 * KRB5_KDB_FLAG_CROSS_REALM: Set by the KDC after looking up a server | |
1037 * entry during a TGS request, if the header ticket was issued by a | |
1038 * different realm. | |
1039 * | |
1040 * KRB5_KDB_FLAG_ISSUING_REFERRAL: Set by the KDC after looking up a server | |
1041 * entry during a TGS request, if the requested server principal is not | |
1042 * part of the realm being served, and a referral or alternate TGT will | |
1043 * be issued instead. | |
1044 * | |
1045 * A module may return an in-realm alias by setting (*entry)->princ to the | |
1046 * canonical name. The KDC will decide based on the request whether to use | |
1047 * the requested name or the canonical name in the issued ticket. | |
1048 * | |
1049 * A module can return a referral to another realm if flags contains | |
1050 * KRB5_KDB_FLAG_REFERRAL_OK. If KRB5_KDB_FLAG_CLIENT is also set, the | |
1051 * module should return a referral by simply filling in an out-of-realm | |
1052 * name in (*entry)->princ and setting all other fields to NULL. | |
1053 * Otherwise, the module should return the entry for the cross-realm TGS of | |
1054 * the referred-to realm. | |
1055 */ | |
1056 krb5_error_code (*get_principal)(krb5_context kcontext, | |
1057 krb5_const_principal search_for, | |
1058 unsigned int flags, | |
1059 krb5_db_entry **entry); | |
1060 | |
1061 /* | |
1062 * Optional: Create or modify a principal entry. db_args communicates | |
1063 * command-line arguments for module-specific flags. | |
1064 * | |
1065 * The mask field of an entry indicates the changed fields. Mask values | |
1066 * are defined in kadmin's admin.h header. If KADM5_PRINCIPAL is set in | |
1067 * the mask, the entry is new; otherwise it already exists. All fields of | |
1068 * an entry are expected to contain correct values, regardless of whether | |
1069 * they are specified in the mask, so it is acceptable for a module to | |
1070 * ignore the mask and update the entire entry. | |
1071 */ | |
1072 krb5_error_code (*put_principal)(krb5_context kcontext, | |
1073 krb5_db_entry *entry, char **db_args); | |
1074 | |
1075 /* | |
1076 * Optional: Delete the entry for the principal search_for. If the | |
1077 * principal did not exist, return KRB5_KDB_NOENTRY. | |
1078 */ | |
1079 krb5_error_code (*delete_principal)(krb5_context kcontext, | |
1080 krb5_const_principal search_for); | |
1081 | |
1082 /* | |
1083 * Optional with default: Rename a principal. If the source principal does | |
1084 * not exist, return KRB5_KDB_NOENTRY. If the target exists, return an | |
1085 * error. | |
1086 * | |
1087 * NOTE: If the module chooses to implement a custom function for renaming | |
1088 * a principal instead of using the default, then rename operations will | |
1089 * fail if iprop logging is enabled. | |
1090 */ | |
1091 krb5_error_code (*rename_principal)(krb5_context kcontext, | |
1092 krb5_const_principal source, | |
1093 krb5_const_principal target); | |
1094 | |
1095 /* | |
1096 * Optional: For each principal entry in the database, invoke func with the | |
1097 * arguments func_arg and the entry data. If match_entry is specified, the | |
1098 * module may narrow the iteration to principal names matching that regular | |
1099 * expression; a module may alternatively ignore match_entry. | |
1100 */ | |
1101 krb5_error_code (*iterate)(krb5_context kcontext, | |
1102 char *match_entry, | |
1103 int (*func)(krb5_pointer, krb5_db_entry *), | |
1104 krb5_pointer func_arg, krb5_flags iterflags); | |
1105 | |
1106 /* | |
1107 * Optional: Create a password policy entry. Return an error if the policy | |
1108 * already exists. | |
1109 */ | |
1110 krb5_error_code (*create_policy)(krb5_context kcontext, | |
1111 osa_policy_ent_t policy); | |
1112 | |
1113 /* | |
1114 * Optional: Set *policy to the policy entry of the specified name. If the | |
1115 * entry does not exist, return KRB5_KDB_NOENTRY. | |
1116 */ | |
1117 krb5_error_code (*get_policy)(krb5_context kcontext, char *name, | |
1118 osa_policy_ent_t *policy); | |
1119 | |
1120 /* | |
1121 * Optional: Modify an existing password policy entry to match the values | |
1122 * in policy. Return an error if the policy does not already exist. | |
1123 */ | |
1124 krb5_error_code (*put_policy)(krb5_context kcontext, | |
1125 osa_policy_ent_t policy); | |
1126 | |
1127 /* | |
1128 * Optional: For each password policy entry in the database, invoke func | |
1129 * with the arguments data and the entry data. If match_entry is | |
1130 * specified, the module may narrow the iteration to policy names matching | |
1131 * that regular expression; a module may alternatively ignore match_entry. | |
1132 */ | |
1133 krb5_error_code (*iter_policy)(krb5_context kcontext, char *match_entry, | |
1134 osa_adb_iter_policy_func func, | |
1135 void *data); | |
1136 | |
1137 /* | |
1138 * Optional: Delete the password policy entry with the name policy. Return | |
1139 * an error if the entry does not exist. | |
1140 */ | |
1141 krb5_error_code (*delete_policy)(krb5_context kcontext, char *policy); | |
1142 | |
1143 /* | |
1144 * Optional with default: Retrieve a master keyblock from the stash file | |
1145 * db_args, filling in *key and *kvno. mname is the name of the master | |
1146 * principal for the realm. | |
1147 * | |
1148 * The default implementation reads the master keyblock from a keytab or | |
1149 * old-format stash file. | |
1150 */ | |
1151 krb5_error_code (*fetch_master_key)(krb5_context kcontext, | |
1152 krb5_principal mname, | |
1153 krb5_keyblock *key, krb5_kvno *kvno, | |
1154 char *db_args); | |
1155 | |
1156 /* | |
1157 * Optional with default: Given a keyblock for some version of the | |
1158 * database's master key, fetch the decrypted master key values from the | |
1159 * database and store the list into *mkeys_list. The caller will free | |
1160 * *mkeys_list using a libkdb5 function which uses the standard free() | |
1161 * function, so the module must not use a custom allocator. | |
1162 * | |
1163 * The caller may not know the version number of the master key it has, in | |
1164 * which case it will pass IGNORE_VNO. | |
1165 * | |
1166 * The default implementation ignores kvno and tries the key against the | |
1167 * current master key data and all KRB5_TL_MKEY_AUX values, which contain | |
1168 * copies of the master keys encrypted with old master keys. | |
1169 */ | |
1170 krb5_error_code (*fetch_master_key_list)(krb5_context kcontext, | |
1171 krb5_principal mname, | |
1172 const krb5_keyblock *key, | |
1173 krb5_keylist_node **mkeys_list); | |
1174 | |
1175 /* | |
1176 * Optional with default: Save a list of master keyblocks, obtained from | |
1177 * fetch_master_key_list, into the stash file db_arg. The caller will set | |
1178 * master_pwd to NULL, so the module should just ignore it. mname is the | |
1179 * name of the master principal for the realm. | |
1180 * | |
1181 * The default implementation saves the list of master keys in a | |
1182 * keytab-format file. | |
1183 */ | |
1184 krb5_error_code (*store_master_key_list)(krb5_context kcontext, | |
1185 char *db_arg, | |
1186 krb5_principal mname, | |
1187 krb5_keylist_node *keylist, | |
1188 char *master_pwd); | |
1189 | |
1190 /* | |
1191 * Optional with default: Starting at position *start, scan the key data of | |
1192 * a database entry for a key matching the enctype ktype, the salt type | |
1193 * stype, and the version kvno. Store the resulting key into *kdatap and | |
1194 * set *start to the position after the key found. If ktype is negative, | |
1195 * match any enctype. If stype is negative, match any salt type. If kvno | |
1196 * is zero or negative, find the most recent key version satisfying the | |
1197 * other constraints. | |
1198 */ | |
1199 krb5_error_code (*dbe_search_enctype)(krb5_context kcontext, | |
1200 krb5_db_entry *dbentp, | |
1201 krb5_int32 *start, krb5_int32 ktype, | |
1202 krb5_int32 stype, krb5_int32 kvno, | |
1203 krb5_key_data **kdatap); | |
1204 | |
1205 | |
1206 /* | |
1207 * Optional with default: Change the key data for db_entry to include keys | |
1208 * derived from the password passwd in each of the specified key-salt | |
1209 * types, at version new_kvno. Discard the old key data if keepold is not | |
1210 * set. | |
1211 * | |
1212 * The default implementation uses the keyblock master_key to encrypt each | |
1213 * new key, via the function encrypt_key_data. | |
1214 */ | |
1215 krb5_error_code (*change_pwd)(krb5_context context, | |
1216 krb5_keyblock *master_key, | |
1217 krb5_key_salt_tuple *ks_tuple, | |
1218 int ks_tuple_count, char *passwd, | |
1219 int new_kvno, krb5_boolean keepold, | |
1220 krb5_db_entry *db_entry); | |
1221 | |
1222 /* | |
1223 * Optional: Promote a temporary database to be the live one. context must | |
1224 * be initialized with an exclusively locked database created with the | |
1225 * "temporary" db_arg. On success, the database object contained in | |
1226 * context will be finalized. | |
1227 * | |
1228 * This method is used by kdb5_util load to replace the live database with | |
1229 * minimal loss of read availability. | |
1230 */ | |
1231 krb5_error_code (*promote_db)(krb5_context context, char *conf_section, | |
1232 char **db_args); | |
1233 | |
1234 /* | |
1235 * Optional with default: Decrypt the key in key_data with master keyblock | |
1236 * mkey, placing the result into dbkey. Copy the salt from key_data, if | |
1237 * any, into keysalt. Either dbkey or keysalt may be left unmodified on | |
1238 * successful return if key_data does not contain key or salt information. | |
1239 * | |
1240 * The default implementation expects the encrypted key (in krb5_c_encrypt | |
1241 * format) to be stored in key_data_contents[0], with length given by | |
1242 * key_data_length[0]. If key_data_ver is 2, it expects the salt to be | |
1243 * stored, unencrypted, in key_data_contents[1], with length given by | |
1244 * key_data_length[1]. | |
1245 */ | |
1246 krb5_error_code (*decrypt_key_data)(krb5_context kcontext, | |
1247 const krb5_keyblock *mkey, | |
1248 const krb5_key_data *key_data, | |
1249 krb5_keyblock *dbkey, | |
1250 krb5_keysalt *keysalt); | |
1251 | |
1252 /* | |
1253 * Optional with default: Encrypt dbkey with master keyblock mkey, placing | |
1254 * the result into key_data along with keysalt. | |
1255 * | |
1256 * The default implementation stores the encrypted key (in krb5_c_encrypt | |
1257 * format) in key_data_contents[0] and the length in key_data_length[0]. | |
1258 * If keysalt is specified, it sets key_data_ver to 2, and stores the salt | |
1259 * in key_data_contents[1] and its length in key_data_length[1]. If | |
1260 * keysalt is not specified, key_data_ver is set to 1. | |
1261 */ | |
1262 krb5_error_code (*encrypt_key_data)(krb5_context kcontext, | |
1263 const krb5_keyblock *mkey, | |
1264 const krb5_keyblock *dbkey, | |
1265 const krb5_keysalt *keysalt, | |
1266 int keyver, krb5_key_data *key_data); | |
1267 | |
1268 /* | |
1269 * Optional: Perform a policy check on a cross-realm ticket's transited | |
1270 * field. Return 0 if the check authoritatively succeeds, | |
1271 * KRB5_PLUGIN_NO_HANDLE to use the core transited-checking mechanisms, or | |
1272 * another error (other than KRB5_PLUGIN_OP_NOTSUPP) if the check fails. | |
1273 */ | |
1274 krb5_error_code (*check_transited_realms)(krb5_context kcontext, | |
1275 const krb5_data *tr_contents, | |
1276 const krb5_data *client_realm, | |
1277 const krb5_data *server_realm); | |
1278 | |
1279 /* | |
1280 * Optional: Perform a policy check on an AS request, in addition to the | |
1281 * standard policy checks. Return 0 if the AS request is allowed. If the | |
1282 * AS request is not allowed: | |
1283 * - Place a short string literal into *status. | |
1284 * - If desired, place data into e_data. Any data placed here will be | |
1285 * freed by the caller using the standard free function. | |
1286 * - Return an appropriate error (such as KRB5KDC_ERR_POLICY). | |
1287 */ | |
1288 krb5_error_code (*check_policy_as)(krb5_context kcontext, | |
1289 krb5_kdc_req *request, | |
1290 krb5_db_entry *client, | |
1291 krb5_db_entry *server, | |
1292 krb5_timestamp kdc_time, | |
1293 const char **status, | |
1294 krb5_pa_data ***e_data); | |
1295 | |
1296 /* | |
1297 * Optional: Perform a policy check on a TGS request, in addition to the | |
1298 * standard policy checks. Return 0 if the TGS request is allowed. If the | |
1299 * TGS request is not allowed: | |
1300 * - Place a short string literal into *status. | |
1301 * - If desired, place data into e_data. Any data placed here will be | |
1302 * freed by the caller using the standard free function. | |
1303 * - Return an appropriate error (such as KRB5KDC_ERR_POLICY). | |
1304 * The input parameter ticket contains the TGT used in the TGS request. | |
1305 */ | |
1306 krb5_error_code (*check_policy_tgs)(krb5_context kcontext, | |
1307 krb5_kdc_req *request, | |
1308 krb5_db_entry *server, | |
1309 krb5_ticket *ticket, | |
1310 const char **status, | |
1311 krb5_pa_data ***e_data); | |
1312 | |
1313 /* | |
1314 * Optional: This method informs the module of a successful or unsuccessful | |
1315 * AS request. | |
1316 */ | |
1317 void (*audit_as_req)(krb5_context kcontext, krb5_kdc_req *request, | |
1318 const krb5_address *local_addr, | |
1319 const krb5_address *remote_addr, | |
1320 krb5_db_entry *client, krb5_db_entry *server, | |
1321 krb5_timestamp authtime, krb5_error_code error_code); | |
1322 | |
1323 /* Note: there is currently no method for auditing TGS requests. */ | |
1324 | |
1325 /* | |
1326 * Optional: This method informs the module of a request to reload | |
1327 * configuration or other state (that is, the KDC received a SIGHUP). | |
1328 */ | |
1329 void (*refresh_config)(krb5_context kcontext); | |
1330 | |
1331 /* | |
1332 * Optional: Perform a policy check on server being allowed to obtain | |
1333 * tickets from client to proxy. If proxy is NULL, check if server has any | |
1334 * authorized delegation targets (client will also be NULL in this case). | |
1335 * (Note that proxy is the target of the delegation, not the delegating | |
1336 * service; the term "proxy" is from the viewpoint of the delegating | |
1337 * service asking another service to perform some of its work in the | |
1338 * authentication context of the client. This terminology comes from the | |
1339 * Microsoft S4U protocol documentation.) Return 0 if policy allows | |
1340 * delegation to the specified target (or to any target if proxy is NULL), | |
1341 * or KRB5KDC_ERR_BADOPTION if not. If this method is not implemented, all | |
1342 * S4U2Proxy delegation requests will be rejected. | |
1343 */ | |
1344 krb5_error_code (*check_allowed_to_delegate)(krb5_context context, | |
1345 krb5_const_principal client, | |
1346 const krb5_db_entry *server, | |
1347 krb5_const_principal proxy); | |
1348 | |
1349 /* | |
1350 * Optional: Free the e_data pointer of a database entry. If this method | |
1351 * is not implemented, the e_data pointer in principal entries will be | |
1352 * freed with free() as seen by libkdb5. | |
1353 */ | |
1354 void (*free_principal_e_data)(krb5_context kcontext, krb5_octet *e_data); | |
1355 | |
1356 /* | |
1357 * Optional: get a client principal entry based on an X.509 certificate. | |
1358 * | |
1359 * If flags include KRB5_KDB_FLAG_REFERRAL_OK, the certificate was | |
1360 * presented in an AS request. princ->realm indicates the request realm, | |
1361 * but the data components should be ignored. The module can return an | |
1362 * out-of-realm client referral as it would for get_principal(). | |
1363 * | |
1364 * Otherwise, princ is from a TGS request. If it contains data components | |
1365 * (and not just a realm), the module should verify that it is the same as | |
1366 * the lookup result for client_cert. The module should not return a | |
1367 * referral. | |
1368 */ | |
1369 krb5_error_code (*get_s4u_x509_principal)(krb5_context kcontext, | |
1370 const krb5_data *client_cert, | |
1371 krb5_const_principal princ, | |
1372 unsigned int flags, | |
1373 krb5_db_entry **entry_out); | |
1374 | |
1375 /* | |
1376 * Optional: Perform a policy check on server being allowed to obtain | |
1377 * tickets from client to proxy. This method is similar to | |
1378 * check_allowed_to_delegate, but it operates on the target server DB entry | |
1379 * (called "proxy" here as in Microsoft's protocol documentation) rather | |
1380 * than the intermediate server entry. server_pac is the verified PAC from | |
1381 * the authdata of the intermediate server. Return 0 if policy allows the | |
1382 * delegation, or KRB5KDC_ERR_BADOPTION if not. | |
1383 * | |
1384 * This method is called for S4U2Proxy requests and implements the | |
1385 * resource-based constrained delegation variant, which can support | |
1386 * cross-realm delegation. If this method is not implemented or if it | |
1387 * returns a policy error, the KDC will fall back to | |
1388 * check_allowed_to_delegate if the intermediate and target servers are in | |
1389 * the same realm and the evidence ticket is forwardable. | |
1390 */ | |
1391 krb5_error_code (*allowed_to_delegate_from)(krb5_context context, | |
1392 krb5_const_principal client, | |
1393 krb5_const_principal server, | |
1394 krb5_pac server_pac, | |
1395 const krb5_db_entry *proxy); | |
1396 | |
1397 /* | |
1398 * Optional: Add buffers to new_pac using krb5_pac_add_buffer() before it | |
1399 * is signed. | |
1400 * | |
1401 * The caller will handle the following buffer types, so do not copy or add | |
1402 * them: | |
1403 * | |
1404 * KRB5_PAC_SERVER_CHECKSUM | |
1405 * KRB5_PAC_PRIVSVR_CHECKSUM | |
1406 * KRB5_PAC_TICKET_CHECKSUM | |
1407 * KRB5_PAC_CLIENT_INFO | |
1408 * KRB5_PAC_DELEGATION_INFO | |
1409 * | |
1410 * For TGS requests, old_pac is the PAC of the header ticket, except when | |
1411 * KRB5_KDB_FLAG_CONTRAINED_DELEGATION is present in flags, in which case | |
1412 * it is the PAC of the second ticket. If | |
1413 * KRB5_KDB_FLAG_PROTOCOL_TRANSITION is present in flags and client is not | |
1414 * NULL, old_pac is the PAC of the requesting service, not the subject of | |
1415 * the S4U2Self request, and its buffers should not be copied into new_pac. | |
1416 * The signatures and PAC_CLIENT_INFO of old_pac have been verified by the | |
1417 * caller. | |
1418 * | |
1419 * If replaced_reply_key is not null, the request is an AS request and the | |
1420 * reply key was replaced by a preauth mechanism such as PKINIT, meaning | |
1421 * the Kerberos password or long-term key was not used. The module may use | |
1422 * this key to encrypt a PAC_CREDENTIALS_INFO buffer containing credentials | |
1423 * (such as an NTLM hash) that the client would ordinarily derive from the | |
1424 * Kerberos password or long-term key. | |
1425 * | |
1426 * server is the database entry of the server the ticket will be issued to, | |
1427 * which may be a referral TGS. | |
1428 * | |
1429 * signing_krbtgt is the database entry of the krbtgt principal used to | |
1430 * verify old_pac (or null if old_pac is null). If | |
1431 * KRB5_KDB_FLAG_CROSS_REALM is present in flags, this entry will be an | |
1432 * incoming cross-realm TGS, and the PAC fields should undergo appropriate | |
1433 * filtering based on the trust level of the cross-realm relationship. | |
1434 * | |
1435 * auth_indicators points to NULL or a null-terminated list of krb5_data | |
1436 * pointers, each containing an authentication indicator (RFC 8129). The | |
1437 * method may modify this list, or free it and replace *auth_indicators | |
1438 * with NULL, to change which auth indicators will be included in the | |
1439 * ticket. | |
1440 */ | |
1441 krb5_error_code (*issue_pac)(krb5_context context, unsigned int flags, | |
1442 krb5_db_entry *client, | |
1443 krb5_keyblock *replaced_reply_key, | |
1444 krb5_db_entry *server, | |
1445 krb5_db_entry *signing_krbtgt, | |
1446 krb5_timestamp authtime, krb5_pac old_pac, | |
1447 krb5_pac new_pac, | |
1448 krb5_data ***auth_indicators); | |
1449 | |
1450 /* End of minor version 0 for major version 9. */ | |
1451 } kdb_vftabl; | |
1452 | |
1453 #endif /* !defined(_WIN32) */ | |
1454 | |
1455 #endif /* KRB5_KDB5__ */ |