/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Copyright 1990, 1991, 2016 by the Massachusetts Institute of Technology.3* All Rights Reserved.4*5* Export of this software from the United States of America may6* require a specific license from the United States Government.7* It is the responsibility of any person or organization contemplating8* export to obtain such a license before exporting.9*10* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and11* distribute this software and its documentation for any purpose and12* without fee is hereby granted, provided that the above copyright13* notice appear in all copies and that both that copyright notice and14* this permission notice appear in supporting documentation, and that15* the name of M.I.T. not be used in advertising or publicity pertaining16* to distribution of the software without specific, written prior17* permission. Furthermore if you modify this software you must label18* your software as modified software and not distribute it in such a19* fashion that it might be confused with the original M.I.T. software.20* M.I.T. makes no representations about the suitability of21* this software for any purpose. It is provided "as is" without express22* or implied warranty.23*/24/*25* Copyright (C) 1998 by the FundsXpress, INC.26*27* All rights reserved.28*29* Export of this software from the United States of America may require30* a specific license from the United States Government. It is the31* responsibility of any person or organization contemplating export to32* obtain such a license before exporting.33*34* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and35* distribute this software and its documentation for any purpose and36* without fee is hereby granted, provided that the above copyright37* notice appear in all copies and that both that copyright notice and38* this permission notice appear in supporting documentation, and that39* the name of FundsXpress. not be used in advertising or publicity pertaining40* to distribution of the software without specific, written prior41* permission. FundsXpress makes no representations about the suitability of42* this software for any purpose. It is provided "as is" without express43* or implied warranty.44*45* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR46* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED47* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.48*/49/*50* Copyright 2009 Sun Microsystems, Inc. All rights reserved.51* Use is subject to license terms.52*/5354/* KDC Database interface definitions */5556/* This API is not considered as stable as the main krb5 API.57*58* - We may make arbitrary incompatible changes between feature59* releases (e.g. from 1.7 to 1.8).60* - We will make some effort to avoid making incompatible changes for61* bugfix releases, but will make them if necessary.62*/6364#ifndef KRB5_KDB5__65#define KRB5_KDB5__6667#include <time.h>68#include <krb5.h>6970/* This version will be incremented when incompatible changes are made to the71* KDB API, and will be kept in sync with the libkdb major version. */72#define KRB5_KDB_API_VERSION 107374/* Salt types */75#define KRB5_KDB_SALTTYPE_NORMAL 076/* #define KRB5_KDB_SALTTYPE_V4 1 */77#define KRB5_KDB_SALTTYPE_NOREALM 278#define KRB5_KDB_SALTTYPE_ONLYREALM 379#define KRB5_KDB_SALTTYPE_SPECIAL 480/* #define KRB5_KDB_SALTTYPE_AFS3 5 */81#define KRB5_KDB_SALTTYPE_CERTHASH 68283/* Attributes */84#define KRB5_KDB_DISALLOW_POSTDATED 0x0000000185#define KRB5_KDB_DISALLOW_FORWARDABLE 0x0000000286#define KRB5_KDB_DISALLOW_TGT_BASED 0x0000000487#define KRB5_KDB_DISALLOW_RENEWABLE 0x0000000888#define KRB5_KDB_DISALLOW_PROXIABLE 0x0000001089#define KRB5_KDB_DISALLOW_DUP_SKEY 0x0000002090#define KRB5_KDB_DISALLOW_ALL_TIX 0x0000004091#define KRB5_KDB_REQUIRES_PRE_AUTH 0x0000008092#define KRB5_KDB_REQUIRES_HW_AUTH 0x0000010093#define KRB5_KDB_REQUIRES_PWCHANGE 0x0000020094#define KRB5_KDB_DISALLOW_SVR 0x0000100095#define KRB5_KDB_PWCHANGE_SERVICE 0x0000200096#define KRB5_KDB_SUPPORT_DESMD5 0x0000400097#define KRB5_KDB_NEW_PRINC 0x0000800098#define KRB5_KDB_OK_AS_DELEGATE 0x0010000099#define KRB5_KDB_OK_TO_AUTH_AS_DELEGATE 0x00200000 /* S4U2Self OK */100#define KRB5_KDB_NO_AUTH_DATA_REQUIRED 0x00400000101#define KRB5_KDB_LOCKDOWN_KEYS 0x00800000102103/* Creation flags */104#define KRB5_KDB_CREATE_BTREE 0x00000001105#define KRB5_KDB_CREATE_HASH 0x00000002106107/* Entry get flags */108/* Okay to generate a referral on lookup */109#define KRB5_KDB_FLAG_REFERRAL_OK 0x00000010110/* Client principal lookup (client referrals only) */111#define KRB5_KDB_FLAG_CLIENT 0x00000040112/* Map cross-realm principals */113#define KRB5_KDB_FLAG_MAP_PRINCIPALS 0x00000080114/* Protocol transition */115#define KRB5_KDB_FLAG_PROTOCOL_TRANSITION 0x00000100116/* Constrained delegation */117#define KRB5_KDB_FLAG_CONSTRAINED_DELEGATION 0x00000200118/* User-to-user */119#define KRB5_KDB_FLAG_USER_TO_USER 0x00000800120/* Cross-realm */121#define KRB5_KDB_FLAG_CROSS_REALM 0x00001000122/* Issuing referral */123#define KRB5_KDB_FLAG_ISSUING_REFERRAL 0x00004000124125126#define KRB5_KDB_FLAGS_S4U ( KRB5_KDB_FLAG_PROTOCOL_TRANSITION | \127KRB5_KDB_FLAG_CONSTRAINED_DELEGATION )128129/* KDB iteration flags */130#define KRB5_DB_ITER_WRITE 0x00000001131#define KRB5_DB_ITER_REV 0x00000002132#define KRB5_DB_ITER_RECURSE 0x00000004133134/* String attribute names recognized by krb5 */135#define KRB5_KDB_SK_PAC_PRIVSVR_ENCTYPE "pac_privsvr_enctype"136#define KRB5_KDB_SK_SESSION_ENCTYPES "session_enctypes"137#define KRB5_KDB_SK_REQUIRE_AUTH "require_auth"138139#if !defined(_WIN32)140141/*142* Note --- these structures cannot be modified without changing the143* database version number in libkdb.a, but should be expandable by144* adding new tl_data types.145*/146typedef struct _krb5_tl_data {147struct _krb5_tl_data* tl_data_next; /* NOT saved */148krb5_int16 tl_data_type;149krb5_ui_2 tl_data_length;150krb5_octet * tl_data_contents;151} krb5_tl_data;152153/* String attributes (currently stored inside tl-data) map C string keys to154* values. They can be set via kadmin and consumed by KDC plugins. */155typedef struct krb5_string_attr_st {156char *key;157char *value;158} krb5_string_attr;159160/*161* If this ever changes up the version number and make the arrays be as162* big as necessary.163*164* Currently the first type is the enctype and the second is the salt type.165*/166typedef struct _krb5_key_data {167krb5_int16 key_data_ver; /* Version */168krb5_ui_2 key_data_kvno; /* Key Version */169krb5_int16 key_data_type[2]; /* Array of types */170krb5_ui_2 key_data_length[2]; /* Array of lengths */171krb5_octet * key_data_contents[2]; /* Array of pointers */172} krb5_key_data;173174#define KRB5_KDB_V1_KEY_DATA_ARRAY 2 /* # of array elements */175176typedef struct _krb5_keysalt {177krb5_int16 type;178krb5_data data; /* Length, data */179} krb5_keysalt;180181/*182* A principal database entry. Extensions to this structure currently use the183* tl_data list. The e_data and e_length fields are not used by any calling184* code except kdb5_util dump and load, which marshal and unmarshal the array185* in the dump record. KDB modules may use these fields internally as long as186* they set e_length appropriately (non-zero if the data should be marshalled187* across dump and load, zero if not) and handle null e_data values in188* caller-constructed principal entries.189*/190typedef struct _krb5_db_entry_new {191krb5_magic magic; /* NOT saved */192krb5_ui_2 len;193krb5_ui_4 mask; /* members currently changed/set */194krb5_flags attributes;195krb5_deltat max_life;196krb5_deltat max_renewable_life;197krb5_timestamp expiration; /* When the client expires */198krb5_timestamp pw_expiration; /* When its passwd expires */199krb5_timestamp last_success; /* Last successful passwd */200krb5_timestamp last_failed; /* Last failed passwd attempt */201krb5_kvno fail_auth_count; /* # of failed passwd attempt */202krb5_int16 n_tl_data;203krb5_int16 n_key_data;204krb5_ui_2 e_length; /* Length of extra data */205krb5_octet * e_data; /* Extra data to be saved */206207krb5_principal princ; /* Length, data */208krb5_tl_data * tl_data; /* Linked list */209210/* key_data must be sorted by kvno in descending order. */211krb5_key_data * key_data; /* Array */212} krb5_db_entry;213214typedef struct _osa_policy_ent_t {215int version;216char *name;217krb5_ui_4 pw_min_life;218krb5_ui_4 pw_max_life;219krb5_ui_4 pw_min_length;220krb5_ui_4 pw_min_classes;221krb5_ui_4 pw_history_num;222krb5_ui_4 policy_refcnt; /* no longer used */223/* Only valid if version > 1 */224krb5_ui_4 pw_max_fail; /* pwdMaxFailure */225krb5_ui_4 pw_failcnt_interval; /* pwdFailureCountInterval */226krb5_ui_4 pw_lockout_duration; /* pwdLockoutDuration */227/* Only valid if version > 2 */228krb5_ui_4 attributes;229krb5_ui_4 max_life;230krb5_ui_4 max_renewable_life;231char * allowed_keysalts;232krb5_int16 n_tl_data;233krb5_tl_data * tl_data;234} osa_policy_ent_rec, *osa_policy_ent_t;235236typedef void (*osa_adb_iter_policy_func) (void *, osa_policy_ent_t);237238typedef struct __krb5_key_salt_tuple {239krb5_enctype ks_enctype;240krb5_int32 ks_salttype;241} krb5_key_salt_tuple;242243#define KRB5_KDB_MAGIC_NUMBER 0xdbdbdbdb244#define KRB5_KDB_V1_BASE_LENGTH 38245246#define KRB5_KDB_MAX_ALLOWED_KS_LEN 512247248#define KRB5_TL_LAST_PWD_CHANGE 0x0001249#define KRB5_TL_MOD_PRINC 0x0002250#define KRB5_TL_KADM_DATA 0x0003251#define KRB5_TL_KADM5_E_DATA 0x0004252#define KRB5_TL_RB1_CHALLENGE 0x0005253#ifdef SECURID254#define KRB5_TL_SECURID_STATE 0x0006255#endif /* SECURID */256#define KRB5_TL_USER_CERTIFICATE 0x0007257#define KRB5_TL_MKVNO 0x0008258#define KRB5_TL_ACTKVNO 0x0009259#define KRB5_TL_MKEY_AUX 0x000a260261/* String attributes may not always be represented in tl-data. kadmin clients262* must use the get_strings and set_string RPCs. */263#define KRB5_TL_STRING_ATTRS 0x000b264265#define KRB5_TL_ALIAS_TARGET 0x000c266267#define KRB5_TL_PAC_LOGON_INFO 0x0100 /* NDR encoded validation info */268#define KRB5_TL_SERVER_REFERRAL 0x0200 /* ASN.1 encoded ServerReferralInfo */269#define KRB5_TL_SVR_REFERRAL_DATA 0x0300 /* ASN.1 encoded PA-SVR-REFERRAL-DATA */270#define KRB5_TL_CONSTRAINED_DELEGATION_ACL 0x0400 /* Each entry is a permitted SPN */271#define KRB5_TL_LM_KEY 0x0500 /* LM OWF */272#define KRB5_TL_X509_SUBJECT_ISSUER_NAME 0x0600 /* <I>IssuerDN<S>SubjectDN */273#define KRB5_TL_LAST_ADMIN_UNLOCK 0x0700 /* Timestamp of admin unlock */274275#define KRB5_TL_DB_ARGS 0x7fff276277/* version number for KRB5_TL_ACTKVNO data */278#define KRB5_TL_ACTKVNO_VER 1279280/* version number for KRB5_TL_MKEY_AUX data */281#define KRB5_TL_MKEY_AUX_VER 1282283typedef struct _krb5_actkvno_node {284struct _krb5_actkvno_node *next;285krb5_kvno act_kvno;286krb5_timestamp act_time;287} krb5_actkvno_node;288289typedef struct _krb5_mkey_aux_node {290struct _krb5_mkey_aux_node *next;291krb5_kvno mkey_kvno; /* kvno of mkey protecting the latest_mkey */292krb5_key_data latest_mkey; /* most recent mkey */293} krb5_mkey_aux_node;294295typedef struct _krb5_keylist_node {296krb5_keyblock keyblock;297krb5_kvno kvno;298struct _krb5_keylist_node *next;299} krb5_keylist_node;300301/*302* Determines the number of failed KDC requests before DISALLOW_ALL_TIX is set303* on the principal.304*/305#define KRB5_MAX_FAIL_COUNT 5306307/* XXX depends on knowledge of krb5_parse_name() formats */308#define KRB5_KDB_M_NAME "K/M" /* Kerberos/Master */309310/* prompts used by default when reading the KDC password from the keyboard. */311#define KRB5_KDC_MKEY_1 "Enter KDC database master key"312#define KRB5_KDC_MKEY_2 "Re-enter KDC database master key to verify"313314315extern char *krb5_mkey_pwd_prompt1;316extern char *krb5_mkey_pwd_prompt2;317318/*319* These macros specify the encoding of data within the database.320*321* Data encoding is little-endian.322*/323#ifdef _KRB5_INT_H324#include "k5-platform.h"325#define krb5_kdb_decode_int16(cp, i16) \326*((krb5_int16 *) &(i16)) = load_16_le(cp)327#define krb5_kdb_decode_int32(cp, i32) \328*((krb5_int32 *) &(i32)) = load_32_le(cp)329#define krb5_kdb_encode_int16(i16, cp) store_16_le(i16, cp)330#define krb5_kdb_encode_int32(i32, cp) store_32_le(i32, cp)331#endif /* _KRB5_INT_H */332333#define KRB5_KDB_OPEN_RW 0334#define KRB5_KDB_OPEN_RO 1335336#ifndef KRB5_KDB_SRV_TYPE_KDC337#define KRB5_KDB_SRV_TYPE_KDC 0x0100338#endif339340#ifndef KRB5_KDB_SRV_TYPE_ADMIN341#define KRB5_KDB_SRV_TYPE_ADMIN 0x0200342#endif343344/* 0x0300 was KRB5_KDB_SRV_TYPE_PASSWD but it is no longer used. */345346#ifndef KRB5_KDB_SRV_TYPE_OTHER347#define KRB5_KDB_SRV_TYPE_OTHER 0x0400348#endif349350#define KRB5_KDB_OPT_SET_DB_NAME 0351#define KRB5_KDB_OPT_SET_LOCK_MODE 1352353#define KRB5_DB_LOCKMODE_SHARED 0x0001354#define KRB5_DB_LOCKMODE_EXCLUSIVE 0x0002355#define KRB5_DB_LOCKMODE_PERMANENT 0x0008356357/*358* Load the specified KDB module, to be used for KDB operations with kcontext.359* This function must be called prior to any KDB operations with kcontext.360* name will be looked up relative to the configured database directories, with361* platform-specific suffixes suitable for shared objects. This function can362* be used to implement one KDB module in terms of another, but the outer363* module must supply a separate krb5_context from the one passed to its364* methods.365*/366krb5_error_code krb5_db_load_module(krb5_context kcontext, const char *name);367368krb5_error_code krb5_db_setup_lib_handle(krb5_context kcontext);369krb5_error_code krb5_db_open( krb5_context kcontext, char **db_args, int mode );370krb5_error_code krb5_db_init ( krb5_context kcontext );371krb5_error_code krb5_db_create ( krb5_context kcontext, char **db_args );372krb5_error_code krb5_db_inited ( krb5_context kcontext );373krb5_error_code kdb5_db_create ( krb5_context kcontext, char **db_args );374krb5_error_code krb5_db_fini ( krb5_context kcontext );375const char * krb5_db_errcode2string ( krb5_context kcontext, long err_code );376krb5_error_code krb5_db_destroy ( krb5_context kcontext, char **db_args );377krb5_error_code krb5_db_promote ( krb5_context kcontext, char **db_args );378krb5_error_code krb5_db_get_age ( krb5_context kcontext, char *db_name, time_t *t );379krb5_error_code krb5_db_lock ( krb5_context kcontext, int lock_mode );380krb5_error_code krb5_db_unlock ( krb5_context kcontext );381krb5_error_code krb5_db_get_principal ( krb5_context kcontext,382krb5_const_principal search_for,383unsigned int flags,384krb5_db_entry **entry );385void krb5_db_free_principal ( krb5_context kcontext, krb5_db_entry *entry );386krb5_error_code krb5_db_put_principal ( krb5_context kcontext,387krb5_db_entry *entry );388krb5_error_code krb5_db_delete_principal ( krb5_context kcontext,389krb5_principal search_for );390krb5_error_code krb5_db_rename_principal ( krb5_context kcontext,391krb5_principal source,392krb5_principal target );393394/*395* Iterate over principals in the KDB. If the callback may write to the DB,396* the caller must get an exclusive lock with krb5_db_lock before iterating,397* and release it with krb5_db_unlock after iterating.398*/399krb5_error_code krb5_db_iterate ( krb5_context kcontext,400char *match_entry,401int (*func) (krb5_pointer, krb5_db_entry *),402krb5_pointer func_arg, krb5_flags iterflags );403404405krb5_error_code krb5_db_store_master_key ( krb5_context kcontext,406char *keyfile,407krb5_principal mname,408krb5_kvno kvno,409krb5_keyblock *key,410char *master_pwd);411krb5_error_code krb5_db_store_master_key_list ( krb5_context kcontext,412char *keyfile,413krb5_principal mname,414char *master_pwd);415krb5_error_code krb5_db_fetch_mkey ( krb5_context context,416krb5_principal mname,417krb5_enctype etype,418krb5_boolean fromkeyboard,419krb5_boolean twice,420char *db_args,421krb5_kvno *kvno,422krb5_data *salt,423krb5_keyblock *key);424krb5_error_code425krb5_db_fetch_mkey_list( krb5_context context,426krb5_principal mname,427const krb5_keyblock * mkey );428429krb5_error_code430krb5_dbe_find_enctype( krb5_context kcontext,431krb5_db_entry *dbentp,432krb5_int32 ktype,433krb5_int32 stype,434krb5_int32 kvno,435krb5_key_data **kdatap);436437438krb5_error_code krb5_dbe_search_enctype ( krb5_context kcontext,439krb5_db_entry *dbentp,440krb5_int32 *start,441krb5_int32 ktype,442krb5_int32 stype,443krb5_int32 kvno,444krb5_key_data **kdatap);445446krb5_error_code447krb5_db_setup_mkey_name ( krb5_context context,448const char *keyname,449const char *realm,450char **fullname,451krb5_principal *principal);452453/**454* Decrypts the key given in @@a key_data. If @a mkey is specified, that455* master key is used. If @a mkey is NULL, then all master keys are tried.456*/457krb5_error_code458krb5_dbe_decrypt_key_data( krb5_context context,459const krb5_keyblock * mkey,460const krb5_key_data * key_data,461krb5_keyblock * dbkey,462krb5_keysalt * keysalt);463464krb5_error_code465krb5_dbe_encrypt_key_data( krb5_context context,466const krb5_keyblock * mkey,467const krb5_keyblock * dbkey,468const krb5_keysalt * keysalt,469int keyver,470krb5_key_data * key_data);471472krb5_error_code473krb5_dbe_fetch_act_key_list(krb5_context context,474krb5_principal princ,475krb5_actkvno_node **act_key_list);476477krb5_error_code478krb5_dbe_find_act_mkey( krb5_context context,479krb5_actkvno_node * act_mkey_list,480krb5_kvno * act_kvno,481krb5_keyblock ** act_mkey);482483krb5_error_code484krb5_dbe_find_mkey( krb5_context context,485krb5_db_entry * entry,486krb5_keyblock ** mkey);487488/* Set *mkvno to mkvno in entry tl_data, or 0 if not present. */489krb5_error_code490krb5_dbe_lookup_mkvno( krb5_context context,491krb5_db_entry * entry,492krb5_kvno * mkvno);493494krb5_keylist_node *495krb5_db_mkey_list_alias( krb5_context kcontext );496497/* Set *mkvno to mkvno in entry tl_data, or minimum value from mkey_list. */498krb5_error_code499krb5_dbe_get_mkvno( krb5_context context,500krb5_db_entry * entry,501krb5_kvno * mkvno);502503krb5_error_code504krb5_dbe_lookup_mod_princ_data( krb5_context context,505krb5_db_entry * entry,506krb5_timestamp * mod_time,507krb5_principal * mod_princ);508509krb5_error_code510krb5_dbe_lookup_mkey_aux( krb5_context context,511krb5_db_entry * entry,512krb5_mkey_aux_node ** mkey_aux_data_list);513krb5_error_code514krb5_dbe_update_mkvno( krb5_context context,515krb5_db_entry * entry,516krb5_kvno mkvno);517518krb5_error_code519krb5_dbe_lookup_actkvno( krb5_context context,520krb5_db_entry * entry,521krb5_actkvno_node ** actkvno_list);522523krb5_error_code524krb5_dbe_update_mkey_aux( krb5_context context,525krb5_db_entry * entry,526krb5_mkey_aux_node * mkey_aux_data_list);527528krb5_error_code529krb5_dbe_update_actkvno(krb5_context context,530krb5_db_entry * entry,531const krb5_actkvno_node *actkvno_list);532533krb5_error_code534krb5_dbe_update_last_pwd_change( krb5_context context,535krb5_db_entry * entry,536krb5_timestamp stamp);537538krb5_error_code539krb5_dbe_update_last_admin_unlock( krb5_context context,540krb5_db_entry * entry,541krb5_timestamp stamp);542543krb5_error_code544krb5_dbe_lookup_tl_data( krb5_context context,545krb5_db_entry * entry,546krb5_tl_data * ret_tl_data);547548krb5_error_code549krb5_dbe_create_key_data( krb5_context context,550krb5_db_entry * entry);551552553krb5_error_code554krb5_dbe_update_mod_princ_data( krb5_context context,555krb5_db_entry * entry,556krb5_timestamp mod_date,557krb5_const_principal mod_princ);558559/*560* These are wrappers around realloc() and free(). Applications and KDB561* modules can use them when manipulating principal and policy entries to562* ensure that they allocate and free memory in a manner compatible with the563* library. Using libkrb5 or libkbd5 functions to construct values (such as564* krb5_copy_principal() to construct the princ field of a krb5_db_entry) is565* also safe. On Unix platforms, just using malloc() and free() is safe as566* long as the application or module does not use a malloc replacement.567*/568void *krb5_db_alloc( krb5_context kcontext,569void *ptr,570size_t size );571void krb5_db_free( krb5_context kcontext,572void *ptr);573574575krb5_error_code576krb5_dbe_lookup_last_pwd_change( krb5_context context,577krb5_db_entry * entry,578krb5_timestamp * stamp);579580krb5_error_code581krb5_dbe_lookup_last_admin_unlock( krb5_context context,582krb5_db_entry * entry,583krb5_timestamp * stamp);584585/* Retrieve the set of string attributes in entry, in no particular order.586* Free *strings_out with krb5_dbe_free_strings when done. */587krb5_error_code588krb5_dbe_get_strings(krb5_context context, krb5_db_entry *entry,589krb5_string_attr **strings_out, int *count_out);590591/* Retrieve a single string attribute from entry, or NULL if there is no592* attribute for key. Free *value_out with krb5_dbe_free_string when done. */593krb5_error_code594krb5_dbe_get_string(krb5_context context, krb5_db_entry *entry,595const char *key, char **value_out);596597/* Change or add a string attribute in entry, or delete it if value is NULL. */598krb5_error_code599krb5_dbe_set_string(krb5_context context, krb5_db_entry *entry,600const char *key, const char *value);601602krb5_error_code603krb5_dbe_delete_tl_data( krb5_context context,604krb5_db_entry * entry,605krb5_int16 tl_data_type);606607krb5_error_code608krb5_db_update_tl_data(krb5_context context,609krb5_int16 * n_tl_datap,610krb5_tl_data **tl_datap,611krb5_tl_data * new_tl_data);612613krb5_error_code614krb5_dbe_update_tl_data( krb5_context context,615krb5_db_entry * entry,616krb5_tl_data * new_tl_data);617618/* Compute the salt for a key data entry given the corresponding principal. */619krb5_error_code620krb5_dbe_compute_salt(krb5_context context, const krb5_key_data *key,621krb5_const_principal princ, krb5_int16 *salttype_out,622krb5_data **salt_out);623624/*625* Modify the key data of entry to explicitly store salt values using the626* KRB5_KDB_SALTTYPE_SPECIAL salt type.627*/628krb5_error_code629krb5_dbe_specialize_salt(krb5_context context, krb5_db_entry *entry);630631krb5_error_code632krb5_dbe_cpw( krb5_context kcontext,633krb5_keyblock * master_key,634krb5_key_salt_tuple * ks_tuple,635int ks_tuple_count,636char * passwd,637int new_kvno,638unsigned int keepold,639krb5_db_entry * db_entry);640641642krb5_error_code643krb5_dbe_ark( krb5_context context,644krb5_keyblock * master_key,645krb5_key_salt_tuple * ks_tuple,646int ks_tuple_count,647krb5_db_entry * db_entry);648649krb5_error_code650krb5_dbe_crk( krb5_context context,651krb5_keyblock * master_key,652krb5_key_salt_tuple * ks_tuple,653int ks_tuple_count,654unsigned int keepold,655krb5_db_entry * db_entry);656657krb5_error_code658krb5_dbe_apw( krb5_context context,659krb5_keyblock * master_key,660krb5_key_salt_tuple * ks_tuple,661int ks_tuple_count,662char * passwd,663krb5_db_entry * db_entry);664665int666krb5_db_get_key_data_kvno( krb5_context context,667int count,668krb5_key_data * data);669670krb5_error_code krb5_db_check_transited_realms(krb5_context kcontext,671const krb5_data *tr_contents,672const krb5_data *client_realm,673const krb5_data *server_realm);674675krb5_error_code krb5_db_check_policy_as(krb5_context kcontext,676krb5_kdc_req *request,677krb5_db_entry *client,678krb5_db_entry *server,679krb5_timestamp kdc_time,680const char **status,681krb5_pa_data ***e_data);682683krb5_error_code krb5_db_check_policy_tgs(krb5_context kcontext,684krb5_kdc_req *request,685krb5_db_entry *server,686krb5_ticket *ticket,687const char **status,688krb5_pa_data ***e_data);689690void krb5_db_audit_as_req(krb5_context kcontext, krb5_kdc_req *request,691const krb5_address *local_addr,692const krb5_address *remote_addr,693krb5_db_entry *client, krb5_db_entry *server,694krb5_timestamp authtime, krb5_error_code error_code);695696void krb5_db_refresh_config(krb5_context kcontext);697698krb5_error_code krb5_db_check_allowed_to_delegate(krb5_context kcontext,699krb5_const_principal client,700const krb5_db_entry *server,701krb5_const_principal proxy);702703krb5_error_code krb5_db_get_s4u_x509_principal(krb5_context kcontext,704const krb5_data *client_cert,705krb5_const_principal in_princ,706unsigned int flags,707krb5_db_entry **entry);708709krb5_error_code krb5_db_allowed_to_delegate_from(krb5_context context,710krb5_const_principal client,711krb5_const_principal server,712krb5_pac server_pac,713const krb5_db_entry *proxy);714715/**716* Sort an array of @a krb5_key_data keys in descending order by their kvno.717* Key data order within a kvno is preserved.718*719* @param key_data720* The @a krb5_key_data array to sort. This is sorted in place so the721* array will be modified.722* @param key_data_length723* The length of @a key_data.724*/725void726krb5_dbe_sort_key_data(krb5_key_data *key_data, size_t key_data_length);727728krb5_error_code729krb5_db_issue_pac(krb5_context context, unsigned int flags,730krb5_db_entry *client, krb5_keyblock *replaced_reply_key,731krb5_db_entry *server, krb5_db_entry *krbtgt,732krb5_timestamp authtime, krb5_pac old_pac, krb5_pac new_pac,733krb5_data ***auth_indicators);734735/* default functions. Should not be directly called */736/*737* Default functions prototype738*/739740krb5_error_code741krb5_dbe_def_search_enctype( krb5_context kcontext,742krb5_db_entry *dbentp,743krb5_int32 *start,744krb5_int32 ktype,745krb5_int32 stype,746krb5_int32 kvno,747krb5_key_data **kdatap);748749krb5_error_code750krb5_def_store_mkey_list( krb5_context context,751char *keyfile,752krb5_principal mname,753krb5_keylist_node *keylist,754char *master_pwd);755756krb5_error_code757krb5_db_def_fetch_mkey( krb5_context context,758krb5_principal mname,759krb5_keyblock *key,760krb5_kvno *kvno,761char *db_args);762763krb5_error_code764krb5_def_fetch_mkey_list( krb5_context context,765krb5_principal mprinc,766const krb5_keyblock *mkey,767krb5_keylist_node **mkeys_list);768769krb5_error_code770krb5_dbe_def_cpw( krb5_context context,771krb5_keyblock * master_key,772krb5_key_salt_tuple * ks_tuple,773int ks_tuple_count,774char * passwd,775int new_kvno,776unsigned int keepold,777krb5_db_entry * db_entry);778779krb5_error_code780krb5_dbe_def_decrypt_key_data( krb5_context context,781const krb5_keyblock * mkey,782const krb5_key_data * key_data,783krb5_keyblock * dbkey,784krb5_keysalt * keysalt);785786krb5_error_code787krb5_dbe_def_encrypt_key_data( krb5_context context,788const krb5_keyblock * mkey,789const krb5_keyblock * dbkey,790const krb5_keysalt * keysalt,791int keyver,792krb5_key_data * key_data);793794krb5_error_code795krb5_db_def_rename_principal( krb5_context kcontext,796krb5_const_principal source,797krb5_const_principal target);798799krb5_error_code800krb5_db_create_policy( krb5_context kcontext,801osa_policy_ent_t policy);802803krb5_error_code804krb5_db_get_policy ( krb5_context kcontext,805char *name,806osa_policy_ent_t *policy );807808krb5_error_code809krb5_db_put_policy( krb5_context kcontext,810osa_policy_ent_t policy);811812krb5_error_code813krb5_db_iter_policy( krb5_context kcontext,814char *match_entry,815osa_adb_iter_policy_func func,816void *data);817818krb5_error_code819krb5_db_delete_policy( krb5_context kcontext,820char *policy);821822void823krb5_db_free_policy( krb5_context kcontext,824osa_policy_ent_t policy);825826827krb5_error_code828krb5_db_set_context(krb5_context, void *db_context);829830krb5_error_code831krb5_db_get_context(krb5_context, void **db_context);832833void834krb5_dbe_free_key_data_contents(krb5_context, krb5_key_data *);835836void837krb5_dbe_free_key_list(krb5_context, krb5_keylist_node *);838839void840krb5_dbe_free_actkvno_list(krb5_context, krb5_actkvno_node *);841842void843krb5_dbe_free_mkey_aux_list(krb5_context, krb5_mkey_aux_node *);844845void846krb5_dbe_free_tl_data(krb5_context, krb5_tl_data *);847848void849krb5_dbe_free_strings(krb5_context, krb5_string_attr *, int count);850851void852krb5_dbe_free_string(krb5_context, char *);853854/* Set *out to a stub alias entry pointing to target. */855krb5_error_code856krb5_dbe_make_alias_entry(krb5_context context, krb5_const_principal alias,857krb5_const_principal target, krb5_db_entry **out);858859/* If entry contains a stub alias entry, set *target_out to the alias target.860* If not, set *target_out to NULL and return 0. */861krb5_error_code862krb5_dbe_read_alias(krb5_context context, krb5_db_entry *entry,863krb5_principal *target_out);864865/*866* Register the KDB keytab type, allowing "KDB:" to be used as a keytab name.867* For this type to work, the context used for keytab operations must have an868* associated database handle (via krb5_db_open()).869*/870krb5_error_code krb5_db_register_keytab(krb5_context context);871872#define KRB5_KDB_DEF_FLAGS 0873874#define KDB_MAX_DB_NAME 128875#define KDB_REALM_SECTION "realms"876#define KDB_MODULE_POINTER "database_module"877#define KDB_MODULE_DEF_SECTION "dbdefaults"878#define KDB_MODULE_SECTION "dbmodules"879#define KDB_LIB_POINTER "db_library"880#define KDB_DATABASE_CONF_FILE DEFAULT_SECURE_PROFILE_PATH881#define KDB_DATABASE_ENV_PROF KDC_PROFILE_ENV882883#define KRB5_KDB_OPEN_RW 0884#define KRB5_KDB_OPEN_RO 1885886#define KRB5_KDB_OPT_SET_DB_NAME 0887#define KRB5_KDB_OPT_SET_LOCK_MODE 1888889/*890* This number indicates the date of the last incompatible change to the DAL.891* The maj_ver field of the module's vtable structure must match this version.892*/893#define KRB5_KDB_DAL_MAJOR_VERSION 9894895/*896* Note the following when converting a module to DAL version 9:897*898* - get_authdata_info() and sign_authdata() have been removed, and issue_pac()899* has been added.900*901* - check_allowed_to_delegate() must handle a null proxy argument, returning902* success if server has any authorized delegation targets in the traditional903* scheme.904*905* - allowed_to_delegate_from() accepts a krb5_pac parameter (in place906* server_ad_info) for the impersonator's PAC.907*908* - check_allowed_to_delegate() and allowed_to_delegate_from() must return909* KRB5KDC_ERR_BADOPTION on authorization failure.910*911* - the KRB5_KDB_FLAG_ISSUE_PAC and KRB5_FLAG_CLIENT_REFERRALS_ONLY flags have912* been combined into KRB5_KDB_FLAG_CLIENT.913*914* - the KRB5_KDB_FLAG_CANONICALIZE flag has been renamed to915* KRB5_KDB_FLAG_REFERRAL_OK, and is only passed to get_principal() when a916* realm referral is allowed (AS client and TGS server lookups, when the917* CANONICALIZE option is requested or, for AS requests, when the client is918* an enterprise principal). As of DAL version 8 the KDB module should919* always canonicalize aliases within a realm; the KDC will decide whether to920* use the original or canonical principal.921*/922923/*924* A krb5_context can hold one database object. Modules should use925* krb5_db_set_context and krb5_db_get_context to store state associated with926* the database object.927*928* Some module functions are mandatory for KDC operation; others are optional929* or apply only to administrative operations. If a function is optional, a930* module can leave the function pointer as NULL. Alternatively, modules can931* return KRB5_PLUGIN_OP_NOTSUPP when asked to perform an inapplicable action.932*933* Some module functions have default implementations which will call back into934* the vtable interface. Leave these functions as NULL to use the default935* implementations.936*937* The documentation in these comments describes the DAL as it is currently938* implemented and used, not as it should be. So if anything seems off, that939* probably means the current state of things is off.940*941* Modules must allocate memory for principal entries, policy entries, and942* other structures using an allocator compatible with malloc() as seen by943* libkdb5 and libkrb5. Modules may link against libkdb5 and call944* krb5_db_alloc() to be certain that the same malloc implementation is used.945*/946947typedef struct _kdb_vftabl {948short int maj_ver;949short int min_ver;950951/*952* Mandatory: Invoked after the module library is loaded, when the first DB953* using the module is opened, across all contexts.954*/955krb5_error_code (*init_library)(void);956957/*958* Mandatory: Invoked before the module library is unloaded, after the last959* DB using the module is closed, across all contexts.960*/961krb5_error_code (*fini_library)(void);962963/*964* Mandatory: Initialize a database object. Profile settings should be965* read from conf_section inside KDB_MODULE_SECTION. db_args communicates966* command-line arguments for module-specific flags. mode will be one of967* KRB5_KDB_OPEN_{RW,RO} or'd with one of968* KRB5_KDB_SRV_TYPE_{KDC,ADMIN,PASSWD,OTHER}.969*/970krb5_error_code (*init_module)(krb5_context kcontext, char *conf_section,971char **db_args, int mode);972973/*974* Mandatory: Finalize the database object contained in a context. Free975* any state contained in the db_context pointer and null it out.976*/977krb5_error_code (*fini_module)(krb5_context kcontext);978979/*980* Optional: Initialize a database object while creating the underlying981* database. conf_section and db_args have the same meaning as in982* init_module. This function may return an error if the database already983* exists. Used by kdb5_util create.984*985* If db_args contains the value "temporary", the module should create an986* exclusively locked side copy of the database suitable for loading in a987* propagation from primary to replica. This side copy will later be988* promoted with promote_db, allowing complete updates of the DB with no989* loss in read availability. If the module cannot comply with this990* architecture, it should return an error.991*/992krb5_error_code (*create)(krb5_context kcontext, char *conf_section,993char **db_args);994995/*996* Optional: Destroy a database. conf_section and db_args have the same997* meaning as in init_module. Used by kdb5_util destroy. In current998* usage, the database is destroyed while open, so the module should handle999* that.1000*/1001krb5_error_code (*destroy)(krb5_context kcontext, char *conf_section,1002char **db_args);10031004/*1005* Deprecated: No longer used as of krb5 1.10; can be removed in the next1006* DAL revision. Modules should leave as NULL.1007*/1008krb5_error_code (*get_age)(krb5_context kcontext, char *db_name,1009time_t *age);10101011/*1012* Optional: Lock the database, with semantics depending on the mode1013* argument:1014*1015* KRB5_DB_LOCKMODE_SHARED: Lock may coexist with other shared locks.1016* KRB5_DB_LOCKMODE_EXCLUSIVE: Lock may not coexist with other locks.1017* KRB5_DB_LOCKMODE_PERMANENT: Exclusive lock surviving process exit.1018*1019* Used by the "kadmin lock" command, incremental propagation, and1020* kdb5_util dump. Incremental propagation support requires shared locks1021* to operate. kdb5_util dump will continue unlocked if the module returns1022* KRB5_PLUGIN_OP_NOTSUPP.1023*/1024krb5_error_code (*lock)(krb5_context kcontext, int mode);10251026/* Optional: Release a lock created with db_lock. */1027krb5_error_code (*unlock)(krb5_context kcontext);10281029/*1030* Mandatory: Set *entry to an allocated entry for the principal1031* search_for. If the principal is not found, return KRB5_KDB_NOENTRY.1032*1033* The meaning of flags are as follows:1034*1035* KRB5_KDB_FLAG_REFERRAL_OK: Set by the KDC when looking up entries for an1036* AS client with canonicalization requested or for an enterprise1037* principal, or for a TGS request server with canonicalization1038* requested. Determines whether the module should return out-of-realm1039* referrals.1040*1041* KRB5_KDB_FLAG_CLIENT: Set by the KDC when looking up a client principal1042* during an AS or TGS request. Affects how the module should return1043* out-of-realm referrals.1044*1045* KRB5_KDB_FLAG_MAP_PRINCIPALS: Set by the KDC when looking up the client1046* entry during TGS requests, except for S4U TGS requests and requests1047* where the server entry has the KRB5_KDB_NO_AUTH_DATA_REQUIRED1048* attribute. Indicates that the module should map foreign principals1049* to local principals if it supports doing so.1050*1051* KRB5_KDB_FLAG_PROTOCOL_TRANSITION: Set by the KDC when looking up the1052* client entry during an S4U2Self TGS request. This affects the PAC1053* information which should be included when authorization data is1054* generated; see the Microsoft S4U specification for details.1055*1056* KRB5_KDB_FLAG_CONSTRAINED_DELEGATION: Set by the KDC when looking up the1057* client entry during an S4U2Proxy TGS request. Also affects PAC1058* generation.1059*1060* KRB5_KDB_FLAG_CROSS_REALM: Set by the KDC after looking up a server1061* entry during a TGS request, if the header ticket was issued by a1062* different realm.1063*1064* KRB5_KDB_FLAG_ISSUING_REFERRAL: Set by the KDC after looking up a server1065* entry during a TGS request, if the requested server principal is not1066* part of the realm being served, and a referral or alternate TGT will1067* be issued instead.1068*1069* A module may return an in-realm alias by setting (*entry)->princ to the1070* canonical name. The KDC will decide based on the request whether to use1071* the requested name or the canonical name in the issued ticket.1072*1073* A module can return a referral to another realm if flags contains1074* KRB5_KDB_FLAG_REFERRAL_OK. If KRB5_KDB_FLAG_CLIENT is also set, the1075* module should return a referral by simply filling in an out-of-realm1076* name in (*entry)->princ and setting all other fields to NULL.1077* Otherwise, the module should return the entry for the cross-realm TGS of1078* the referred-to realm.1079*/1080krb5_error_code (*get_principal)(krb5_context kcontext,1081krb5_const_principal search_for,1082unsigned int flags,1083krb5_db_entry **entry);10841085/*1086* Optional: Create or modify a principal entry. db_args communicates1087* command-line arguments for module-specific flags.1088*1089* The mask field of an entry indicates the changed fields. Mask values1090* are defined in kadmin's admin.h header. If KADM5_PRINCIPAL is set in1091* the mask, the entry is new; otherwise it already exists. All fields of1092* an entry are expected to contain correct values, regardless of whether1093* they are specified in the mask, so it is acceptable for a module to1094* ignore the mask and update the entire entry.1095*1096* If the module has its own representation of principal aliases, this1097* method should recognize alias stub entries using krb5_dbe_read_alias()1098* and should create the alias instead of storing the stub entry.1099*/1100krb5_error_code (*put_principal)(krb5_context kcontext,1101krb5_db_entry *entry, char **db_args);11021103/*1104* Optional: Delete search_for from the database. If the principal did not1105* exist, return KRB5_KDB_NOENTRY. If search_for is an alias, delete the1106* alias, not the entry for the canonical principal.1107*/1108krb5_error_code (*delete_principal)(krb5_context kcontext,1109krb5_const_principal search_for);11101111/*1112* Optional with default: Rename a principal. If the source principal does1113* not exist, return KRB5_KDB_NOENTRY. If the target exists, return an1114* error. This method will not be called if source is an alias.1115*1116* NOTE: If the module chooses to implement a custom function for renaming1117* a principal instead of using the default, then rename operations will1118* fail if iprop logging is enabled.1119*/1120krb5_error_code (*rename_principal)(krb5_context kcontext,1121krb5_const_principal source,1122krb5_const_principal target);11231124/*1125* Optional: For each principal entry in the database, invoke func with the1126* arguments func_arg and the entry data. If match_entry is specified, the1127* module may narrow the iteration to principal names matching that regular1128* expression; a module may alternatively ignore match_entry.1129*1130* If the module has its own representation of principal aliases, this1131* method should invoke func with a stub alias entry for each alias,1132* created using krb5_dbe_make_alias_entry().1133*/1134krb5_error_code (*iterate)(krb5_context kcontext,1135char *match_entry,1136int (*func)(krb5_pointer, krb5_db_entry *),1137krb5_pointer func_arg, krb5_flags iterflags);11381139/*1140* Optional: Create a password policy entry. Return an error if the policy1141* already exists.1142*/1143krb5_error_code (*create_policy)(krb5_context kcontext,1144osa_policy_ent_t policy);11451146/*1147* Optional: Set *policy to the policy entry of the specified name. If the1148* entry does not exist, return KRB5_KDB_NOENTRY.1149*/1150krb5_error_code (*get_policy)(krb5_context kcontext, char *name,1151osa_policy_ent_t *policy);11521153/*1154* Optional: Modify an existing password policy entry to match the values1155* in policy. Return an error if the policy does not already exist.1156*/1157krb5_error_code (*put_policy)(krb5_context kcontext,1158osa_policy_ent_t policy);11591160/*1161* Optional: For each password policy entry in the database, invoke func1162* with the arguments data and the entry data. If match_entry is1163* specified, the module may narrow the iteration to policy names matching1164* that regular expression; a module may alternatively ignore match_entry.1165*/1166krb5_error_code (*iter_policy)(krb5_context kcontext, char *match_entry,1167osa_adb_iter_policy_func func,1168void *data);11691170/*1171* Optional: Delete the password policy entry with the name policy. Return1172* an error if the entry does not exist.1173*/1174krb5_error_code (*delete_policy)(krb5_context kcontext, char *policy);11751176/*1177* Optional with default: Retrieve a master keyblock from the stash file1178* db_args, filling in *key and *kvno. mname is the name of the master1179* principal for the realm.1180*1181* The default implementation reads the master keyblock from a keytab or1182* old-format stash file.1183*/1184krb5_error_code (*fetch_master_key)(krb5_context kcontext,1185krb5_principal mname,1186krb5_keyblock *key, krb5_kvno *kvno,1187char *db_args);11881189/*1190* Optional with default: Given a keyblock for some version of the1191* database's master key, fetch the decrypted master key values from the1192* database and store the list into *mkeys_list. The caller will free1193* *mkeys_list using a libkdb5 function which uses the standard free()1194* function, so the module must not use a custom allocator.1195*1196* The caller may not know the version number of the master key it has, in1197* which case it will pass IGNORE_VNO.1198*1199* The default implementation ignores kvno and tries the key against the1200* current master key data and all KRB5_TL_MKEY_AUX values, which contain1201* copies of the master keys encrypted with old master keys.1202*/1203krb5_error_code (*fetch_master_key_list)(krb5_context kcontext,1204krb5_principal mname,1205const krb5_keyblock *key,1206krb5_keylist_node **mkeys_list);12071208/*1209* Optional with default: Save a list of master keyblocks, obtained from1210* fetch_master_key_list, into the stash file db_arg. The caller will set1211* master_pwd to NULL, so the module should just ignore it. mname is the1212* name of the master principal for the realm.1213*1214* The default implementation saves the list of master keys in a1215* keytab-format file.1216*/1217krb5_error_code (*store_master_key_list)(krb5_context kcontext,1218char *db_arg,1219krb5_principal mname,1220krb5_keylist_node *keylist,1221char *master_pwd);12221223/*1224* Optional with default: Starting at position *start, scan the key data of1225* a database entry for a key matching the enctype ktype, the salt type1226* stype, and the version kvno. Store the resulting key into *kdatap and1227* set *start to the position after the key found. If ktype is negative,1228* match any enctype. If stype is negative, match any salt type. If kvno1229* is zero or negative, find the most recent key version satisfying the1230* other constraints.1231*/1232krb5_error_code (*dbe_search_enctype)(krb5_context kcontext,1233krb5_db_entry *dbentp,1234krb5_int32 *start, krb5_int32 ktype,1235krb5_int32 stype, krb5_int32 kvno,1236krb5_key_data **kdatap);123712381239/*1240* Optional with default: Change the key data for db_entry to include keys1241* derived from the password passwd in each of the specified key-salt1242* types, at version new_kvno. Discard the old key data if keepold is not1243* set.1244*1245* The default implementation uses the keyblock master_key to encrypt each1246* new key, via the function encrypt_key_data.1247*/1248krb5_error_code (*change_pwd)(krb5_context context,1249krb5_keyblock *master_key,1250krb5_key_salt_tuple *ks_tuple,1251int ks_tuple_count, char *passwd,1252int new_kvno, unsigned int keepold,1253krb5_db_entry *db_entry);12541255/*1256* Optional: Promote a temporary database to be the live one. context must1257* be initialized with an exclusively locked database created with the1258* "temporary" db_arg. On success, the database object contained in1259* context will be finalized.1260*1261* This method is used by kdb5_util load to replace the live database with1262* minimal loss of read availability.1263*/1264krb5_error_code (*promote_db)(krb5_context context, char *conf_section,1265char **db_args);12661267/*1268* Optional with default: Decrypt the key in key_data with master keyblock1269* mkey, placing the result into dbkey. Copy the salt from key_data, if1270* any, into keysalt. Either dbkey or keysalt may be left unmodified on1271* successful return if key_data does not contain key or salt information.1272*1273* The default implementation expects the encrypted key (in krb5_c_encrypt1274* format) to be stored in key_data_contents[0], with length given by1275* key_data_length[0]. If key_data_ver is 2, it expects the salt to be1276* stored, unencrypted, in key_data_contents[1], with length given by1277* key_data_length[1].1278*/1279krb5_error_code (*decrypt_key_data)(krb5_context kcontext,1280const krb5_keyblock *mkey,1281const krb5_key_data *key_data,1282krb5_keyblock *dbkey,1283krb5_keysalt *keysalt);12841285/*1286* Optional with default: Encrypt dbkey with master keyblock mkey, placing1287* the result into key_data along with keysalt.1288*1289* The default implementation stores the encrypted key (in krb5_c_encrypt1290* format) in key_data_contents[0] and the length in key_data_length[0].1291* If keysalt is specified, it sets key_data_ver to 2, and stores the salt1292* in key_data_contents[1] and its length in key_data_length[1]. If1293* keysalt is not specified, key_data_ver is set to 1.1294*/1295krb5_error_code (*encrypt_key_data)(krb5_context kcontext,1296const krb5_keyblock *mkey,1297const krb5_keyblock *dbkey,1298const krb5_keysalt *keysalt,1299int keyver, krb5_key_data *key_data);13001301/*1302* Optional: Perform a policy check on a cross-realm ticket's transited1303* field. Return 0 if the check authoritatively succeeds,1304* KRB5_PLUGIN_NO_HANDLE to use the core transited-checking mechanisms, or1305* another error (other than KRB5_PLUGIN_OP_NOTSUPP) if the check fails.1306*/1307krb5_error_code (*check_transited_realms)(krb5_context kcontext,1308const krb5_data *tr_contents,1309const krb5_data *client_realm,1310const krb5_data *server_realm);13111312/*1313* Optional: Perform a policy check on an AS request, in addition to the1314* standard policy checks. Return 0 if the AS request is allowed. If the1315* AS request is not allowed:1316* - Place a short string literal into *status.1317* - If desired, place data into e_data. Any data placed here will be1318* freed by the caller using the standard free function.1319* - Return an appropriate error (such as KRB5KDC_ERR_POLICY).1320*/1321krb5_error_code (*check_policy_as)(krb5_context kcontext,1322krb5_kdc_req *request,1323krb5_db_entry *client,1324krb5_db_entry *server,1325krb5_timestamp kdc_time,1326const char **status,1327krb5_pa_data ***e_data);13281329/*1330* Optional: Perform a policy check on a TGS request, in addition to the1331* standard policy checks. Return 0 if the TGS request is allowed. If the1332* TGS request is not allowed:1333* - Place a short string literal into *status.1334* - If desired, place data into e_data. Any data placed here will be1335* freed by the caller using the standard free function.1336* - Return an appropriate error (such as KRB5KDC_ERR_POLICY).1337* The input parameter ticket contains the TGT used in the TGS request.1338*/1339krb5_error_code (*check_policy_tgs)(krb5_context kcontext,1340krb5_kdc_req *request,1341krb5_db_entry *server,1342krb5_ticket *ticket,1343const char **status,1344krb5_pa_data ***e_data);13451346/*1347* Optional: This method informs the module of a successful or unsuccessful1348* AS request.1349*/1350void (*audit_as_req)(krb5_context kcontext, krb5_kdc_req *request,1351const krb5_address *local_addr,1352const krb5_address *remote_addr,1353krb5_db_entry *client, krb5_db_entry *server,1354krb5_timestamp authtime, krb5_error_code error_code);13551356/* Note: there is currently no method for auditing TGS requests. */13571358/*1359* Optional: This method informs the module of a request to reload1360* configuration or other state (that is, the KDC received a SIGHUP).1361*/1362void (*refresh_config)(krb5_context kcontext);13631364/*1365* Optional: Perform a policy check on server being allowed to obtain1366* tickets from client to proxy. If proxy is NULL, check if server has any1367* authorized delegation targets (client will also be NULL in this case).1368* (Note that proxy is the target of the delegation, not the delegating1369* service; the term "proxy" is from the viewpoint of the delegating1370* service asking another service to perform some of its work in the1371* authentication context of the client. This terminology comes from the1372* Microsoft S4U protocol documentation.) Return 0 if policy allows1373* delegation to the specified target (or to any target if proxy is NULL),1374* or KRB5KDC_ERR_BADOPTION if not. If this method is not implemented, all1375* S4U2Proxy delegation requests will be rejected.1376*/1377krb5_error_code (*check_allowed_to_delegate)(krb5_context context,1378krb5_const_principal client,1379const krb5_db_entry *server,1380krb5_const_principal proxy);13811382/*1383* Optional: Free the e_data pointer of a database entry. If this method1384* is not implemented, the e_data pointer in principal entries will be1385* freed with free() as seen by libkdb5.1386*/1387void (*free_principal_e_data)(krb5_context kcontext, krb5_octet *e_data);13881389/*1390* Optional: get a client principal entry based on an X.509 certificate.1391*1392* If flags include KRB5_KDB_FLAG_REFERRAL_OK, the certificate was1393* presented in an AS request. princ->realm indicates the request realm,1394* but the data components should be ignored. The module can return an1395* out-of-realm client referral as it would for get_principal().1396*1397* Otherwise, princ is from a TGS request. If it contains data components1398* (and not just a realm), the module should verify that it is the same as1399* the lookup result for client_cert. The module should not return a1400* referral.1401*/1402krb5_error_code (*get_s4u_x509_principal)(krb5_context kcontext,1403const krb5_data *client_cert,1404krb5_const_principal princ,1405unsigned int flags,1406krb5_db_entry **entry_out);14071408/*1409* Optional: Perform a policy check on server being allowed to obtain1410* tickets from client to proxy. This method is similar to1411* check_allowed_to_delegate, but it operates on the target server DB entry1412* (called "proxy" here as in Microsoft's protocol documentation) rather1413* than the intermediate server entry. server_pac is the verified PAC from1414* the authdata of the intermediate server. Return 0 if policy allows the1415* delegation, or KRB5KDC_ERR_BADOPTION if not.1416*1417* This method is called for S4U2Proxy requests and implements the1418* resource-based constrained delegation variant, which can support1419* cross-realm delegation. If this method is not implemented or if it1420* returns a policy error, the KDC will fall back to1421* check_allowed_to_delegate if the intermediate and target servers are in1422* the same realm and the evidence ticket is forwardable.1423*/1424krb5_error_code (*allowed_to_delegate_from)(krb5_context context,1425krb5_const_principal client,1426krb5_const_principal server,1427krb5_pac server_pac,1428const krb5_db_entry *proxy);14291430/*1431* Optional: Add buffers to new_pac using krb5_pac_add_buffer() before it1432* is signed.1433*1434* The caller will handle the following buffer types, so do not copy or add1435* them:1436*1437* KRB5_PAC_SERVER_CHECKSUM1438* KRB5_PAC_PRIVSVR_CHECKSUM1439* KRB5_PAC_TICKET_CHECKSUM1440* KRB5_PAC_CLIENT_INFO1441* KRB5_PAC_DELEGATION_INFO1442*1443* For TGS requests, old_pac is the PAC of the header ticket, except when1444* KRB5_KDB_FLAG_CONTRAINED_DELEGATION is present in flags, in which case1445* it is the PAC of the second ticket. If1446* KRB5_KDB_FLAG_PROTOCOL_TRANSITION is present in flags and client is not1447* NULL, old_pac is the PAC of the requesting service, not the subject of1448* the S4U2Self request, and its buffers should not be copied into new_pac.1449* The signatures and PAC_CLIENT_INFO of old_pac have been verified by the1450* caller.1451*1452* If replaced_reply_key is not null, the request is an AS request and the1453* reply key was replaced by a preauth mechanism such as PKINIT, meaning1454* the Kerberos password or long-term key was not used. The module may use1455* this key to encrypt a PAC_CREDENTIALS_INFO buffer containing credentials1456* (such as an NTLM hash) that the client would ordinarily derive from the1457* Kerberos password or long-term key.1458*1459* server is the database entry of the server the ticket will be issued to,1460* which may be a referral TGS.1461*1462* signing_krbtgt is the database entry of the krbtgt principal used to1463* verify old_pac (or null if old_pac is null). If1464* KRB5_KDB_FLAG_CROSS_REALM is present in flags, this entry will be an1465* incoming cross-realm TGS, and the PAC fields should undergo appropriate1466* filtering based on the trust level of the cross-realm relationship.1467*1468* auth_indicators points to NULL or a null-terminated list of krb5_data1469* pointers, each containing an authentication indicator (RFC 8129). The1470* method may modify this list, or free it and replace *auth_indicators1471* with NULL, to change which auth indicators will be included in the1472* ticket.1473*/1474krb5_error_code (*issue_pac)(krb5_context context, unsigned int flags,1475krb5_db_entry *client,1476krb5_keyblock *replaced_reply_key,1477krb5_db_entry *server,1478krb5_db_entry *signing_krbtgt,1479krb5_timestamp authtime, krb5_pac old_pac,1480krb5_pac new_pac,1481krb5_data ***auth_indicators);14821483/* End of minor version 0 for major version 9. */1484} kdb_vftabl;14851486#endif /* !defined(_WIN32) */14871488#endif /* KRB5_KDB5__ */148914901491