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