2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
9 * Copyright 1990 by the Massachusetts Institute of Technology.
11 * Export of this software from the United States of America may
12 * require a specific license from the United States Government.
13 * It is the responsibility of any person or organization contemplating
14 * export to obtain such a license before exporting.
16 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
17 * distribute this software and its documentation for any purpose and
18 * without fee is hereby granted, provided that the above copyright
19 * notice appear in all copies and that both that copyright notice and
20 * this permission notice appear in supporting documentation, and that
21 * the name of M.I.T. not be used in advertising or publicity pertaining
22 * to distribution of the software without specific, written prior
23 * permission. Furthermore if you modify this software you must label
24 * your software as modified software and not distribute it in such a
25 * fashion that it might be confused with the original M.I.T. software.
26 * M.I.T. makes no representations about the suitability of
27 * this software for any purpose. It is provided "as is" without express
28 * or implied warranty.
31 * Declarations for policy.c
34 #ifndef __KRB5_KDC_UTIL__
35 #define __KRB5_KDC_UTIL__
44 typedef struct _krb5_fulladdr
{
45 krb5_address
* address
;
49 krb5_error_code
check_hot_list (krb5_ticket
*);
50 krb5_boolean
realm_compare (krb5_principal
, krb5_principal
);
51 krb5_boolean
krb5_is_tgs_principal (krb5_principal
);
52 krb5_error_code
add_to_transited (krb5_data
*,
57 krb5_error_code
compress_transited (krb5_data
*,
60 krb5_error_code
concat_authorization_data (krb5_authdata
**,
63 krb5_error_code
fetch_last_req_info (krb5_db_entry
*,
64 krb5_last_req_entry
***);
66 krb5_error_code
kdc_convert_key (krb5_keyblock
*,
69 krb5_error_code kdc_process_tgs_req
71 const krb5_fulladdr
*,
76 krb5_error_code
kdc_get_server_key (krb5_ticket
*,
80 int validate_as_request (krb5_kdc_req
*, krb5_db_entry
,
81 krb5_db_entry
, krb5_timestamp
,
84 int validate_tgs_request (krb5_kdc_req
*, krb5_db_entry
,
85 krb5_ticket
*, krb5_timestamp
,
88 int fetch_asn1_field (unsigned char *, unsigned int, unsigned int,
92 dbentry_has_key_for_enctype (krb5_context context
,
93 krb5_db_entry
*client
,
94 krb5_enctype enctype
);
97 dbentry_supports_enctype (krb5_context context
,
98 krb5_db_entry
*client
,
99 krb5_enctype enctype
);
102 select_session_keytype (krb5_context context
,
103 krb5_db_entry
*server
,
105 krb5_enctype
*ktypes
);
108 get_salt_from_key (krb5_context
, krb5_principal
,
109 krb5_key_data
*, krb5_data
*);
111 void limit_string (char *name
);
114 ktypes2str(char *s
, size_t len
, int nktypes
, krb5_enctype
*ktype
);
117 rep_etypes2str(char *s
, size_t len
, krb5_kdc_rep
*rep
);
120 krb5_error_code
process_as_req (krb5_kdc_req
*, krb5_data
*,
121 const krb5_fulladdr
*,
125 krb5_error_code
process_tgs_req (krb5_data
*,
126 const krb5_fulladdr
*,
129 krb5_error_code
dispatch (krb5_data
*,
130 const krb5_fulladdr
*,
134 krb5_error_code
kdc_initialize_rcache (krb5_context
, char *);
136 krb5_error_code
setup_server_realm (krb5_principal
);
139 krb5_error_code
listen_and_process (const char *);
140 krb5_error_code
setup_network (const char *);
141 krb5_error_code
closedown_network (const char *);
144 int against_local_policy_as (krb5_kdc_req
*, krb5_db_entry
,
145 krb5_db_entry
, krb5_timestamp
,
148 int against_local_policy_tgs (krb5_kdc_req
*, krb5_db_entry
,
149 krb5_ticket
*, const char **);
152 const char * missing_required_preauth
153 (krb5_db_entry
*client
, krb5_db_entry
*server
,
154 krb5_enc_tkt_part
*enc_tkt_reply
);
155 void get_preauth_hint_list (krb5_kdc_req
* request
,
156 krb5_db_entry
*client
,
157 krb5_db_entry
*server
,
159 krb5_error_code
load_preauth_plugins(krb5_context context
);
160 krb5_error_code
unload_preauth_plugins(krb5_context context
);
162 krb5_error_code check_padata
163 (krb5_context context
, krb5_db_entry
*client
, krb5_data
*req_pkt
,
164 krb5_kdc_req
*request
, krb5_enc_tkt_part
*enc_tkt_reply
,
165 void **padata_context
, krb5_data
*e_data
);
167 krb5_error_code return_padata
168 (krb5_context context
, krb5_db_entry
*client
,
169 krb5_data
*req_pkt
, krb5_kdc_req
*request
, krb5_kdc_rep
*reply
,
170 krb5_key_data
*client_key
, krb5_keyblock
*encrypting_key
,
171 void **padata_context
);
173 krb5_error_code free_padata_context
174 (krb5_context context
, void **padata_context
);
177 krb5_boolean
kdc_check_lookaside (krb5_data
*, krb5_data
**);
178 void kdc_insert_lookaside (krb5_data
*, krb5_data
*);
179 void kdc_free_lookaside(krb5_context
);
181 /* which way to convert key? */
182 #define CONVERT_INTO_DB 0
183 #define CONVERT_OUTOF_DB 1
185 #define isflagset(flagfield, flag) (flagfield & (flag))
186 #define setflag(flagfield, flag) (flagfield |= (flag))
187 #define clear(flagfield, flag) (flagfield &= ~(flag))
189 #ifdef KRB5_KRB4_COMPAT
190 krb5_error_code
process_v4 (const krb5_data
*,
191 const krb5_fulladdr
*,
193 void process_v4_mode (const char *, const char *);
194 void enable_v4_crossrealm(char *);
196 #define process_v4(foo,bar,quux,foobar) KRB5KRB_AP_ERR_BADVERSION
200 #define min(a, b) ((a) < (b) ? (a) : (b))
201 #define max(a, b) ((a) > (b) ? (a) : (b))
204 #ifdef KRB5_USE_INET6
205 #define ADDRTYPE2FAMILY(X) \
206 ((X) == ADDRTYPE_INET6 ? AF_INET6 : (X) == ADDRTYPE_INET ? AF_INET : -1)
208 #define ADDRTYPE2FAMILY(X) \
209 ((X) == ADDRTYPE_INET ? AF_INET : -1)
212 /* RFC 4120: KRB5KDC_ERR_KEY_TOO_WEAK
213 * RFC 4556: KRB5KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED */
214 #define KRB5KDC_ERR_KEY_TOO_WEAK KRB5KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED
220 #endif /* !__KRB5_KDC_UTIL__ */