s3:rpcclient: use rpc_pipe->desthost instead of cli->desthost
[Samba/gebeck_regimport.git] / source4 / auth / kerberos / kerberos.h
blob31794b8e0346f262e5dadfe7ff22cf418d4d5cef
1 /*
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 3 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, see <http://www.gnu.org/licenses/>.
21 #ifndef _AUTH_KERBEROS_H_
22 #define _AUTH_KERBEROS_H_
24 #if defined(HAVE_KRB5)
26 #include "auth/kerberos/krb5_init_context.h"
27 #include "librpc/gen_ndr/krb5pac.h"
28 #include "libcli/auth/krb5_wrap.h"
30 struct auth_user_info_dc;
31 struct cli_credentials;
33 struct ccache_container {
34 struct smb_krb5_context *smb_krb5_context;
35 krb5_ccache ccache;
38 struct keytab_container {
39 struct smb_krb5_context *smb_krb5_context;
40 krb5_keytab keytab;
43 /* not really ASN.1, but RFC 1964 */
44 #define TOK_ID_KRB_AP_REQ ((const uint8_t *)"\x01\x00")
45 #define TOK_ID_KRB_AP_REP ((const uint8_t *)"\x02\x00")
46 #define TOK_ID_KRB_ERROR ((const uint8_t *)"\x03\x00")
47 #define TOK_ID_GSS_GETMIC ((const uint8_t *)"\x01\x01")
48 #define TOK_ID_GSS_WRAP ((const uint8_t *)"\x02\x01")
50 #ifdef HAVE_KRB5_KEYBLOCK_KEYVALUE
51 #define KRB5_KEY_TYPE(k) ((k)->keytype)
52 #define KRB5_KEY_LENGTH(k) ((k)->keyvalue.length)
53 #define KRB5_KEY_DATA(k) ((k)->keyvalue.data)
54 #else
55 #define KRB5_KEY_TYPE(k) ((k)->enctype)
56 #define KRB5_KEY_LENGTH(k) ((k)->length)
57 #define KRB5_KEY_DATA(k) ((k)->contents)
58 #endif /* HAVE_KRB5_KEYBLOCK_KEYVALUE */
60 #define ENC_ALL_TYPES (ENC_CRC32 | ENC_RSA_MD5 | ENC_RC4_HMAC_MD5 | \
61 ENC_HMAC_SHA1_96_AES128 | ENC_HMAC_SHA1_96_AES256)
63 #ifndef HAVE_KRB5_SET_REAL_TIME
64 krb5_error_code krb5_set_real_time(krb5_context context, int32_t seconds, int32_t microseconds);
65 #endif
67 #ifndef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES
68 krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc);
69 #endif
71 #if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
72 krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock *keyblock);
73 #endif
75 #ifndef HAVE_KRB5_FREE_UNPARSED_NAME
76 void krb5_free_unparsed_name(krb5_context ctx, char *val);
77 #endif
79 #if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING) && !defined(HAVE_KRB5_PRINC_COMPONENT)
80 const krb5_data *krb5_princ_component(krb5_context context, krb5_principal principal, int i );
81 #endif
83 /* Samba wrapper function for krb5 functionality. */
84 void setup_kaddr( krb5_address *pkaddr, struct sockaddr *paddr);
85 int create_kerberos_key_from_string(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype);
86 int create_kerberos_key_from_string_direct(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype);
87 krb5_const_principal get_principal_from_tkt(krb5_ticket *tkt);
88 krb5_error_code get_kerberos_allowed_etypes(krb5_context context, krb5_enctype **enctypes);
89 void free_kerberos_etypes(krb5_context context, krb5_enctype *enctypes);
90 bool get_krb5_smb_session_key(krb5_context context, krb5_auth_context auth_context, DATA_BLOB *session_key, bool remote);
91 krb5_error_code ads_krb5_mk_req(krb5_context context,
92 krb5_auth_context *auth_context,
93 const krb5_flags ap_req_options,
94 const char *principal,
95 krb5_ccache ccache,
96 krb5_data *outbuf);
97 bool get_auth_data_from_tkt(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, krb5_ticket *tkt);
98 krb5_error_code kerberos_kinit_password_cc(krb5_context ctx, krb5_ccache cc,
99 krb5_principal principal, const char *password,
100 krb5_principal impersonate_principal,
101 const char *self_service,
102 const char *target_service,
103 krb5_get_init_creds_opt *krb_options,
104 time_t *expire_time, time_t *kdc_time);
105 krb5_error_code kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc,
106 krb5_principal principal, krb5_keyblock *keyblock,
107 const char *target_service,
108 krb5_get_init_creds_opt *krb_options,
109 time_t *expire_time, time_t *kdc_time);
110 krb5_principal kerberos_fetch_salt_princ_for_host_princ(krb5_context context,
111 krb5_principal host_princ,
112 int enctype);
113 void kerberos_set_creds_enctype(krb5_creds *pcreds, int enctype);
114 bool kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, krb5_enctype enctype2);
115 void kerberos_free_data_contents(krb5_context context, krb5_data *pdata);
116 krb5_error_code smb_krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *kt_entry);
117 char *smb_get_krb5_error_message(krb5_context context, krb5_error_code code, TALLOC_CTX *mem_ctx);
118 NTSTATUS kerberos_pac_logon_info(TALLOC_CTX *mem_ctx,
119 DATA_BLOB blob,
120 krb5_context context,
121 const krb5_keyblock *krbtgt_keyblock,
122 const krb5_keyblock *service_keyblock,
123 krb5_const_principal client_principal,
124 time_t tgs_authtime,
125 struct PAC_LOGON_INFO **logon_info);
126 krb5_error_code kerberos_encode_pac(TALLOC_CTX *mem_ctx,
127 struct PAC_DATA *pac_data,
128 krb5_context context,
129 const krb5_keyblock *krbtgt_keyblock,
130 const krb5_keyblock *service_keyblock,
131 DATA_BLOB *pac);
132 krb5_error_code kerberos_create_pac(TALLOC_CTX *mem_ctx,
133 struct auth_user_info_dc *user_info_dc,
134 krb5_context context,
135 const krb5_keyblock *krbtgt_keyblock,
136 const krb5_keyblock *service_keyblock,
137 krb5_principal client_principal,
138 time_t tgs_authtime,
139 DATA_BLOB *pac);
140 struct loadparm_context;
141 struct ldb_message;
142 struct ldb_context;
143 uint32_t kerberos_enctype_to_bitmap(krb5_enctype enc_type_enum);
144 /* Translate between the Microsoft msDS-SupportedEncryptionTypes values and the IETF encryption type values */
145 krb5_enctype kerberos_enctype_bitmap_to_enctype(uint32_t enctype_bitmap);
146 krb5_error_code smb_krb5_update_keytab(TALLOC_CTX *parent_ctx,
147 struct smb_krb5_context *smb_krb5_context,
148 struct ldb_context *ldb,
149 struct ldb_message *msg,
150 bool delete_all_kvno,
151 const char **error_string);
153 #include "auth/kerberos/proto.h"
155 #endif /* HAVE_KRB5 */
157 #endif /* _AUTH_KERBEROS_H_ */