xref: /minix3/crypto/external/bsd/heimdal/dist/lib/kadm5/admin.h (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc /*	$NetBSD: admin.h,v 1.1.1.2 2011/04/14 14:09:16 elric Exp $	*/
2*ebfedea0SLionel Sambuc 
3*ebfedea0SLionel Sambuc /*
4*ebfedea0SLionel Sambuc  * Copyright (c) 1997-2000 Kungliga Tekniska Högskolan
5*ebfedea0SLionel Sambuc  * (Royal Institute of Technology, Stockholm, Sweden).
6*ebfedea0SLionel Sambuc  * All rights reserved.
7*ebfedea0SLionel Sambuc  *
8*ebfedea0SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
9*ebfedea0SLionel Sambuc  * modification, are permitted provided that the following conditions
10*ebfedea0SLionel Sambuc  * are met:
11*ebfedea0SLionel Sambuc  *
12*ebfedea0SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
13*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
14*ebfedea0SLionel Sambuc  *
15*ebfedea0SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
16*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
17*ebfedea0SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
18*ebfedea0SLionel Sambuc  *
19*ebfedea0SLionel Sambuc  * 3. Neither the name of the Institute nor the names of its contributors
20*ebfedea0SLionel Sambuc  *    may be used to endorse or promote products derived from this software
21*ebfedea0SLionel Sambuc  *    without specific prior written permission.
22*ebfedea0SLionel Sambuc  *
23*ebfedea0SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24*ebfedea0SLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25*ebfedea0SLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26*ebfedea0SLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27*ebfedea0SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28*ebfedea0SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29*ebfedea0SLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30*ebfedea0SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31*ebfedea0SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32*ebfedea0SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33*ebfedea0SLionel Sambuc  * SUCH DAMAGE.
34*ebfedea0SLionel Sambuc  */
35*ebfedea0SLionel Sambuc /* Id */
36*ebfedea0SLionel Sambuc 
37*ebfedea0SLionel Sambuc #ifndef __KADM5_ADMIN_H__
38*ebfedea0SLionel Sambuc #define __KADM5_ADMIN_H__
39*ebfedea0SLionel Sambuc 
40*ebfedea0SLionel Sambuc #define KADM5_API_VERSION_1 1
41*ebfedea0SLionel Sambuc #define KADM5_API_VERSION_2 2
42*ebfedea0SLionel Sambuc 
43*ebfedea0SLionel Sambuc #ifndef USE_KADM5_API_VERSION
44*ebfedea0SLionel Sambuc #define USE_KADM5_API_VERSION KADM5_API_VERSION_2
45*ebfedea0SLionel Sambuc #endif
46*ebfedea0SLionel Sambuc 
47*ebfedea0SLionel Sambuc #if USE_KADM5_API_VERSION != KADM5_API_VERSION_2
48*ebfedea0SLionel Sambuc #error No support for API versions other than 2
49*ebfedea0SLionel Sambuc #endif
50*ebfedea0SLionel Sambuc 
51*ebfedea0SLionel Sambuc #define KADM5_STRUCT_VERSION 0
52*ebfedea0SLionel Sambuc 
53*ebfedea0SLionel Sambuc #include <krb5/krb5.h>
54*ebfedea0SLionel Sambuc 
55*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_POSTDATED	0x00000001
56*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_FORWARDABLE	0x00000002
57*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_TGT_BASED	0x00000004
58*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_RENEWABLE	0x00000008
59*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_PROXIABLE	0x00000010
60*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_DUP_SKEY	0x00000020
61*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_ALL_TIX	0x00000040
62*ebfedea0SLionel Sambuc #define KRB5_KDB_REQUIRES_PRE_AUTH	0x00000080
63*ebfedea0SLionel Sambuc #define KRB5_KDB_REQUIRES_HW_AUTH	0x00000100
64*ebfedea0SLionel Sambuc #define KRB5_KDB_REQUIRES_PWCHANGE	0x00000200
65*ebfedea0SLionel Sambuc #define KRB5_KDB_DISALLOW_SVR		0x00001000
66*ebfedea0SLionel Sambuc #define KRB5_KDB_PWCHANGE_SERVICE	0x00002000
67*ebfedea0SLionel Sambuc #define KRB5_KDB_SUPPORT_DESMD5		0x00004000
68*ebfedea0SLionel Sambuc #define KRB5_KDB_NEW_PRINC		0x00008000
69*ebfedea0SLionel Sambuc #define KRB5_KDB_OK_AS_DELEGATE		0x00010000
70*ebfedea0SLionel Sambuc #define KRB5_KDB_TRUSTED_FOR_DELEGATION	0x00020000
71*ebfedea0SLionel Sambuc #define KRB5_KDB_ALLOW_KERBEROS4	0x00040000
72*ebfedea0SLionel Sambuc #define KRB5_KDB_ALLOW_DIGEST		0x00080000
73*ebfedea0SLionel Sambuc 
74*ebfedea0SLionel Sambuc #define KADM5_PRINCIPAL		0x000001
75*ebfedea0SLionel Sambuc #define KADM5_PRINC_EXPIRE_TIME	0x000002
76*ebfedea0SLionel Sambuc #define KADM5_PW_EXPIRATION	0x000004
77*ebfedea0SLionel Sambuc #define KADM5_LAST_PWD_CHANGE	0x000008
78*ebfedea0SLionel Sambuc #define KADM5_ATTRIBUTES	0x000010
79*ebfedea0SLionel Sambuc #define KADM5_MAX_LIFE		0x000020
80*ebfedea0SLionel Sambuc #define KADM5_MOD_TIME		0x000040
81*ebfedea0SLionel Sambuc #define KADM5_MOD_NAME		0x000080
82*ebfedea0SLionel Sambuc #define KADM5_KVNO		0x000100
83*ebfedea0SLionel Sambuc #define KADM5_MKVNO		0x000200
84*ebfedea0SLionel Sambuc #define KADM5_AUX_ATTRIBUTES	0x000400
85*ebfedea0SLionel Sambuc #define KADM5_POLICY		0x000800
86*ebfedea0SLionel Sambuc #define KADM5_POLICY_CLR	0x001000
87*ebfedea0SLionel Sambuc #define KADM5_MAX_RLIFE		0x002000
88*ebfedea0SLionel Sambuc #define KADM5_LAST_SUCCESS	0x004000
89*ebfedea0SLionel Sambuc #define KADM5_LAST_FAILED	0x008000
90*ebfedea0SLionel Sambuc #define KADM5_FAIL_AUTH_COUNT	0x010000
91*ebfedea0SLionel Sambuc #define KADM5_KEY_DATA		0x020000
92*ebfedea0SLionel Sambuc #define KADM5_TL_DATA		0x040000
93*ebfedea0SLionel Sambuc 
94*ebfedea0SLionel Sambuc #define KADM5_PRINCIPAL_NORMAL_MASK (~(KADM5_KEY_DATA | KADM5_TL_DATA))
95*ebfedea0SLionel Sambuc 
96*ebfedea0SLionel Sambuc #define KADM5_PW_MAX_LIFE 	0x004000
97*ebfedea0SLionel Sambuc #define KADM5_PW_MIN_LIFE	0x008000
98*ebfedea0SLionel Sambuc #define KADM5_PW_MIN_LENGTH 	0x010000
99*ebfedea0SLionel Sambuc #define KADM5_PW_MIN_CLASSES	0x020000
100*ebfedea0SLionel Sambuc #define KADM5_PW_HISTORY_NUM	0x040000
101*ebfedea0SLionel Sambuc #define KADM5_REF_COUNT		0x080000
102*ebfedea0SLionel Sambuc 
103*ebfedea0SLionel Sambuc #define KADM5_POLICY_NORMAL_MASK (~0)
104*ebfedea0SLionel Sambuc 
105*ebfedea0SLionel Sambuc #define KADM5_ADMIN_SERVICE	"kadmin/admin"
106*ebfedea0SLionel Sambuc #define KADM5_HIST_PRINCIPAL	"kadmin/history"
107*ebfedea0SLionel Sambuc #define KADM5_CHANGEPW_SERVICE	"kadmin/changepw"
108*ebfedea0SLionel Sambuc 
109*ebfedea0SLionel Sambuc typedef struct {
110*ebfedea0SLionel Sambuc     int16_t key_data_ver;	/* Version */
111*ebfedea0SLionel Sambuc     int16_t key_data_kvno;	/* Key Version */
112*ebfedea0SLionel Sambuc     int16_t key_data_type[2];	/* Array of types */
113*ebfedea0SLionel Sambuc     int16_t key_data_length[2];	/* Array of lengths */
114*ebfedea0SLionel Sambuc     void*   key_data_contents[2];/* Array of pointers */
115*ebfedea0SLionel Sambuc } krb5_key_data;
116*ebfedea0SLionel Sambuc 
117*ebfedea0SLionel Sambuc typedef struct _krb5_tl_data {
118*ebfedea0SLionel Sambuc     struct _krb5_tl_data* tl_data_next;
119*ebfedea0SLionel Sambuc     int16_t tl_data_type;
120*ebfedea0SLionel Sambuc     int16_t tl_data_length;
121*ebfedea0SLionel Sambuc     void*   tl_data_contents;
122*ebfedea0SLionel Sambuc } krb5_tl_data;
123*ebfedea0SLionel Sambuc 
124*ebfedea0SLionel Sambuc #define KRB5_TL_LAST_PWD_CHANGE		0x0001
125*ebfedea0SLionel Sambuc #define KRB5_TL_MOD_PRINC		0x0002
126*ebfedea0SLionel Sambuc #define KRB5_TL_KADM_DATA		0x0003
127*ebfedea0SLionel Sambuc #define KRB5_TL_KADM5_E_DATA		0x0004
128*ebfedea0SLionel Sambuc #define KRB5_TL_RB1_CHALLENGE		0x0005
129*ebfedea0SLionel Sambuc #define KRB5_TL_SECURID_STATE           0x0006
130*ebfedea0SLionel Sambuc #define KRB5_TL_PASSWORD           	0x0007
131*ebfedea0SLionel Sambuc #define KRB5_TL_EXTENSION           	0x0008
132*ebfedea0SLionel Sambuc #define KRB5_TL_PKINIT_ACL           	0x0009
133*ebfedea0SLionel Sambuc #define KRB5_TL_ALIASES           	0x000a
134*ebfedea0SLionel Sambuc 
135*ebfedea0SLionel Sambuc typedef struct _kadm5_principal_ent_t {
136*ebfedea0SLionel Sambuc     krb5_principal principal;
137*ebfedea0SLionel Sambuc 
138*ebfedea0SLionel Sambuc     krb5_timestamp princ_expire_time;
139*ebfedea0SLionel Sambuc     krb5_timestamp last_pwd_change;
140*ebfedea0SLionel Sambuc     krb5_timestamp pw_expiration;
141*ebfedea0SLionel Sambuc     krb5_deltat max_life;
142*ebfedea0SLionel Sambuc     krb5_principal mod_name;
143*ebfedea0SLionel Sambuc     krb5_timestamp mod_date;
144*ebfedea0SLionel Sambuc     krb5_flags attributes;
145*ebfedea0SLionel Sambuc     krb5_kvno kvno;
146*ebfedea0SLionel Sambuc     krb5_kvno mkvno;
147*ebfedea0SLionel Sambuc 
148*ebfedea0SLionel Sambuc     char * policy;
149*ebfedea0SLionel Sambuc     uint32_t aux_attributes;
150*ebfedea0SLionel Sambuc 
151*ebfedea0SLionel Sambuc     krb5_deltat max_renewable_life;
152*ebfedea0SLionel Sambuc     krb5_timestamp last_success;
153*ebfedea0SLionel Sambuc     krb5_timestamp last_failed;
154*ebfedea0SLionel Sambuc     krb5_kvno fail_auth_count;
155*ebfedea0SLionel Sambuc     int16_t n_key_data;
156*ebfedea0SLionel Sambuc     int16_t n_tl_data;
157*ebfedea0SLionel Sambuc     krb5_tl_data *tl_data;
158*ebfedea0SLionel Sambuc     krb5_key_data *key_data;
159*ebfedea0SLionel Sambuc } kadm5_principal_ent_rec, *kadm5_principal_ent_t;
160*ebfedea0SLionel Sambuc 
161*ebfedea0SLionel Sambuc typedef struct _kadm5_policy_ent_t {
162*ebfedea0SLionel Sambuc     char *policy;
163*ebfedea0SLionel Sambuc 
164*ebfedea0SLionel Sambuc     uint32_t pw_min_life;
165*ebfedea0SLionel Sambuc     uint32_t pw_max_life;
166*ebfedea0SLionel Sambuc     uint32_t pw_min_length;
167*ebfedea0SLionel Sambuc     uint32_t pw_min_classes;
168*ebfedea0SLionel Sambuc     uint32_t pw_history_num;
169*ebfedea0SLionel Sambuc     uint32_t policy_refcnt;
170*ebfedea0SLionel Sambuc } kadm5_policy_ent_rec, *kadm5_policy_ent_t;
171*ebfedea0SLionel Sambuc 
172*ebfedea0SLionel Sambuc #define KADM5_CONFIG_REALM			(1 << 0)
173*ebfedea0SLionel Sambuc #define KADM5_CONFIG_PROFILE			(1 << 1)
174*ebfedea0SLionel Sambuc #define KADM5_CONFIG_KADMIND_PORT		(1 << 2)
175*ebfedea0SLionel Sambuc #define KADM5_CONFIG_ADMIN_SERVER		(1 << 3)
176*ebfedea0SLionel Sambuc #define KADM5_CONFIG_DBNAME			(1 << 4)
177*ebfedea0SLionel Sambuc #define KADM5_CONFIG_ADBNAME			(1 << 5)
178*ebfedea0SLionel Sambuc #define KADM5_CONFIG_ADB_LOCKFILE		(1 << 6)
179*ebfedea0SLionel Sambuc #define KADM5_CONFIG_ACL_FILE			(1 << 7)
180*ebfedea0SLionel Sambuc #define KADM5_CONFIG_DICT_FILE			(1 << 8)
181*ebfedea0SLionel Sambuc #define KADM5_CONFIG_ADMIN_KEYTAB		(1 << 9)
182*ebfedea0SLionel Sambuc #define KADM5_CONFIG_MKEY_FROM_KEYBOARD		(1 << 10)
183*ebfedea0SLionel Sambuc #define KADM5_CONFIG_STASH_FILE			(1 << 11)
184*ebfedea0SLionel Sambuc #define KADM5_CONFIG_MKEY_NAME			(1 << 12)
185*ebfedea0SLionel Sambuc #define KADM5_CONFIG_ENCTYPE			(1 << 13)
186*ebfedea0SLionel Sambuc #define KADM5_CONFIG_MAX_LIFE			(1 << 14)
187*ebfedea0SLionel Sambuc #define KADM5_CONFIG_MAX_RLIFE			(1 << 15)
188*ebfedea0SLionel Sambuc #define KADM5_CONFIG_EXPIRATION			(1 << 16)
189*ebfedea0SLionel Sambuc #define KADM5_CONFIG_FLAGS			(1 << 17)
190*ebfedea0SLionel Sambuc #define KADM5_CONFIG_ENCTYPES			(1 << 18)
191*ebfedea0SLionel Sambuc 
192*ebfedea0SLionel Sambuc #define KADM5_PRIV_GET		(1 << 0)
193*ebfedea0SLionel Sambuc #define KADM5_PRIV_ADD 		(1 << 1)
194*ebfedea0SLionel Sambuc #define KADM5_PRIV_MODIFY	(1 << 2)
195*ebfedea0SLionel Sambuc #define KADM5_PRIV_DELETE	(1 << 3)
196*ebfedea0SLionel Sambuc #define KADM5_PRIV_LIST		(1 << 4)
197*ebfedea0SLionel Sambuc #define KADM5_PRIV_CPW		(1 << 5)
198*ebfedea0SLionel Sambuc #define KADM5_PRIV_ALL		(KADM5_PRIV_GET | KADM5_PRIV_ADD | KADM5_PRIV_MODIFY | KADM5_PRIV_DELETE | KADM5_PRIV_LIST | KADM5_PRIV_CPW)
199*ebfedea0SLionel Sambuc 
200*ebfedea0SLionel Sambuc typedef struct {
201*ebfedea0SLionel Sambuc     int XXX;
202*ebfedea0SLionel Sambuc }krb5_key_salt_tuple;
203*ebfedea0SLionel Sambuc 
204*ebfedea0SLionel Sambuc typedef struct _kadm5_config_params {
205*ebfedea0SLionel Sambuc     uint32_t mask;
206*ebfedea0SLionel Sambuc 
207*ebfedea0SLionel Sambuc     /* Client and server fields */
208*ebfedea0SLionel Sambuc     char *realm;
209*ebfedea0SLionel Sambuc     int kadmind_port;
210*ebfedea0SLionel Sambuc 
211*ebfedea0SLionel Sambuc     /* client fields */
212*ebfedea0SLionel Sambuc     char *admin_server;
213*ebfedea0SLionel Sambuc 
214*ebfedea0SLionel Sambuc     /* server fields */
215*ebfedea0SLionel Sambuc     char *dbname;
216*ebfedea0SLionel Sambuc     char *acl_file;
217*ebfedea0SLionel Sambuc 
218*ebfedea0SLionel Sambuc     /* server library (database) fields */
219*ebfedea0SLionel Sambuc     char *stash_file;
220*ebfedea0SLionel Sambuc } kadm5_config_params;
221*ebfedea0SLionel Sambuc 
222*ebfedea0SLionel Sambuc typedef krb5_error_code kadm5_ret_t;
223*ebfedea0SLionel Sambuc 
224*ebfedea0SLionel Sambuc #include "kadm5-protos.h"
225*ebfedea0SLionel Sambuc 
226*ebfedea0SLionel Sambuc #if 0
227*ebfedea0SLionel Sambuc /* unimplemented functions */
228*ebfedea0SLionel Sambuc kadm5_ret_t
229*ebfedea0SLionel Sambuc kadm5_decrypt_key(void *server_handle,
230*ebfedea0SLionel Sambuc 		  kadm5_principal_ent_t entry, int32_t
231*ebfedea0SLionel Sambuc 		  ktype, int32_t stype, int32_t
232*ebfedea0SLionel Sambuc 		  kvno, krb5_keyblock *keyblock,
233*ebfedea0SLionel Sambuc 		  krb5_keysalt *keysalt, int *kvnop);
234*ebfedea0SLionel Sambuc 
235*ebfedea0SLionel Sambuc kadm5_ret_t
236*ebfedea0SLionel Sambuc kadm5_create_policy(void *server_handle,
237*ebfedea0SLionel Sambuc 		    kadm5_policy_ent_t policy, uint32_t mask);
238*ebfedea0SLionel Sambuc 
239*ebfedea0SLionel Sambuc kadm5_ret_t
240*ebfedea0SLionel Sambuc kadm5_delete_policy(void *server_handle, char *policy);
241*ebfedea0SLionel Sambuc 
242*ebfedea0SLionel Sambuc 
243*ebfedea0SLionel Sambuc kadm5_ret_t
244*ebfedea0SLionel Sambuc kadm5_modify_policy(void *server_handle,
245*ebfedea0SLionel Sambuc 		    kadm5_policy_ent_t policy,
246*ebfedea0SLionel Sambuc 		    uint32_t mask);
247*ebfedea0SLionel Sambuc 
248*ebfedea0SLionel Sambuc kadm5_ret_t
249*ebfedea0SLionel Sambuc kadm5_get_policy(void *server_handle, char *policy, kadm5_policy_ent_t ent);
250*ebfedea0SLionel Sambuc 
251*ebfedea0SLionel Sambuc kadm5_ret_t
252*ebfedea0SLionel Sambuc kadm5_get_policies(void *server_handle, char *exp,
253*ebfedea0SLionel Sambuc 		   char ***pols, int *count);
254*ebfedea0SLionel Sambuc 
255*ebfedea0SLionel Sambuc void
256*ebfedea0SLionel Sambuc kadm5_free_policy_ent(kadm5_policy_ent_t policy);
257*ebfedea0SLionel Sambuc 
258*ebfedea0SLionel Sambuc #endif
259*ebfedea0SLionel Sambuc 
260*ebfedea0SLionel Sambuc #endif /* __KADM5_ADMIN_H__ */
261