2 Unix SMB/CIFS implementation.
3 simple kerberos5 routines for active directory
4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) Luke Howard 2002-2003
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #if defined(HAVE_KRB5)
24 /* not really ASN.1, but RFC 1964 */
25 #define TOK_ID_KRB_AP_REQ "\x01\x00"
26 #define TOK_ID_KRB_AP_REP "\x02\x00"
27 #define TOK_ID_KRB_ERROR "\x03\x00"
28 #define TOK_ID_GSS_GETMIC "\x01\x01"
29 #define TOK_ID_GSS_WRAP "\x02\x01"
31 #ifdef HAVE_KRB5_KEYBLOCK_KEYVALUE
32 #define KRB5_KEY_TYPE(k) ((k)->keytype)
33 #define KRB5_KEY_LENGTH(k) ((k)->keyvalue.length)
34 #define KRB5_KEY_DATA(k) ((k)->keyvalue.data)
36 #define KRB5_KEY_TYPE(k) ((k)->enctype)
37 #define KRB5_KEY_LENGTH(k) ((k)->length)
38 #define KRB5_KEY_DATA(k) ((k)->contents)
39 #endif /* HAVE_KRB5_KEYBLOCK_KEYVALUE */
41 #ifndef HAVE_KRB5_SET_REAL_TIME
42 krb5_error_code krb5_set_real_time(krb5_context context, int32_t seconds, int32_t microseconds);
45 #ifndef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES
46 krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc);
49 #if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
50 krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock *keyblock);
53 #ifndef HAVE_KRB5_FREE_UNPARSED_NAME
54 void krb5_free_unparsed_name(krb5_context ctx, char *val);
57 #if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING) && !defined(HAVE_KRB5_PRINC_COMPONENT)
58 const krb5_data *krb5_princ_component(krb5_context context, krb5_principal principal, int i );
61 /* Samba wrapper function for krb5 functionality. */
62 void setup_kaddr( krb5_address *pkaddr, struct sockaddr *paddr);
63 int create_kerberos_key_from_string(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype);
64 int create_kerberos_key_from_string_direct(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype);
65 krb5_const_principal get_principal_from_tkt(krb5_ticket *tkt);
66 krb5_error_code krb5_locate_kdc(krb5_context ctx, const krb5_data *realm, struct sockaddr **addr_pp, int *naddrs, int get_masters);
67 krb5_error_code get_kerberos_allowed_etypes(krb5_context context, krb5_enctype **enctypes);
68 void free_kerberos_etypes(krb5_context context, krb5_enctype *enctypes);
69 BOOL get_krb5_smb_session_key(krb5_context context, krb5_auth_context auth_context, DATA_BLOB *session_key, BOOL remote);
70 krb5_error_code ads_krb5_mk_req(krb5_context context,
71 krb5_auth_context *auth_context,
72 const krb5_flags ap_req_options,
73 const char *principal,
76 DATA_BLOB get_auth_data_from_tkt(TALLOC_CTX *mem_ctx,
79 NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx,
81 krb5_auth_context auth_context,
82 const char *realm, const char *service,
83 const DATA_BLOB *ticket,
84 char **principal, DATA_BLOB *auth_data,
86 krb5_keyblock *keyblock);
87 int kerberos_kinit_password_cc(krb5_context ctx, krb5_ccache cc,
88 const char *principal, const char *password,
89 time_t *expire_time, time_t *kdc_time);
90 krb5_principal kerberos_fetch_salt_princ_for_host_princ(krb5_context context,
91 krb5_principal host_princ,
93 void kerberos_set_creds_enctype(krb5_creds *pcreds, int enctype);
94 BOOL kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, krb5_enctype enctype2);
95 void kerberos_free_data_contents(krb5_context context, krb5_data *pdata);
96 krb5_error_code smb_krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *kt_entry);
97 char *smb_get_krb5_error_message(krb5_context context, krb5_error_code code, TALLOC_CTX *mem_ctx);
98 #endif /* HAVE_KRB5 */