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