| 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
|
|---|
| 6 | Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
|
|---|
| 7 | Copyright (C) Guenther Deschner 2005-2009
|
|---|
| 8 |
|
|---|
| 9 | This program is free software; you can redistribute it and/or modify
|
|---|
| 10 | it under the terms of the GNU General Public License as published by
|
|---|
| 11 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 12 | (at your option) any later version.
|
|---|
| 13 |
|
|---|
| 14 | This program is distributed in the hope that it will be useful,
|
|---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | GNU General Public License for more details.
|
|---|
| 18 |
|
|---|
| 19 | You should have received a copy of the GNU General Public License
|
|---|
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 21 | */
|
|---|
| 22 |
|
|---|
| 23 | #ifndef _INCLUDE_KRB5_PROTOS_H_
|
|---|
| 24 | #define _INCLUDE_KRB5_PROTOS_H_
|
|---|
| 25 |
|
|---|
| 26 | struct PAC_DATA;
|
|---|
| 27 | struct PAC_SIGNATURE_DATA;
|
|---|
| 28 |
|
|---|
| 29 | /* work around broken krb5.h on sles9 */
|
|---|
| 30 | #ifdef SIZEOF_LONG
|
|---|
| 31 | #undef SIZEOF_LONG
|
|---|
| 32 | #endif
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | #if defined(HAVE_KRB5)
|
|---|
| 36 | krb5_error_code smb_krb5_parse_name(krb5_context context,
|
|---|
| 37 | const char *name, /* in unix charset */
|
|---|
| 38 | krb5_principal *principal);
|
|---|
| 39 |
|
|---|
| 40 | krb5_error_code smb_krb5_unparse_name(TALLOC_CTX *mem_ctx,
|
|---|
| 41 | krb5_context context,
|
|---|
| 42 | krb5_const_principal principal,
|
|---|
| 43 | char **unix_name);
|
|---|
| 44 |
|
|---|
| 45 | #ifndef HAVE_KRB5_SET_REAL_TIME
|
|---|
| 46 | krb5_error_code krb5_set_real_time(krb5_context context, int32_t seconds, int32_t microseconds);
|
|---|
| 47 | #endif
|
|---|
| 48 |
|
|---|
| 49 | krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc);
|
|---|
| 50 |
|
|---|
| 51 | #if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
|
|---|
| 52 | krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock *keyblock);
|
|---|
| 53 | #endif
|
|---|
| 54 |
|
|---|
| 55 | #ifndef HAVE_KRB5_FREE_UNPARSED_NAME
|
|---|
| 56 | void krb5_free_unparsed_name(krb5_context ctx, char *val);
|
|---|
| 57 | #endif
|
|---|
| 58 |
|
|---|
| 59 | /* Stub out initialize_krb5_error_table since it is not present in all
|
|---|
| 60 | * Kerberos implementations. If it's not present, it's not necessary to
|
|---|
| 61 | * call it.
|
|---|
| 62 | */
|
|---|
| 63 | #ifndef HAVE_INITIALIZE_KRB5_ERROR_TABLE
|
|---|
| 64 | #define initialize_krb5_error_table()
|
|---|
| 65 | #endif
|
|---|
| 66 |
|
|---|
| 67 | /* The following definitions come from libsmb/clikrb5.c */
|
|---|
| 68 |
|
|---|
| 69 | /* Samba wrapper function for krb5 functionality. */
|
|---|
| 70 | bool setup_kaddr( krb5_address *pkaddr, struct sockaddr_storage *paddr);
|
|---|
| 71 | int create_kerberos_key_from_string(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype, bool no_salt);
|
|---|
| 72 | bool get_auth_data_from_tkt(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, krb5_ticket *tkt);
|
|---|
| 73 | krb5_const_principal get_principal_from_tkt(krb5_ticket *tkt);
|
|---|
| 74 | krb5_error_code get_kerberos_allowed_etypes(krb5_context context, krb5_enctype **enctypes);
|
|---|
| 75 | bool get_krb5_smb_session_key(TALLOC_CTX *mem_ctx,
|
|---|
| 76 | krb5_context context,
|
|---|
| 77 | krb5_auth_context auth_context,
|
|---|
| 78 | DATA_BLOB *session_key, bool remote);
|
|---|
| 79 | krb5_error_code smb_krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *kt_entry);
|
|---|
| 80 | krb5_principal kerberos_fetch_salt_princ_for_host_princ(krb5_context context, krb5_principal host_princ, int enctype);
|
|---|
| 81 | void kerberos_set_creds_enctype(krb5_creds *pcreds, int enctype);
|
|---|
| 82 | bool kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, krb5_enctype enctype2);
|
|---|
| 83 | void kerberos_free_data_contents(krb5_context context, krb5_data *pdata);
|
|---|
| 84 | NTSTATUS decode_pac_data(TALLOC_CTX *mem_ctx,
|
|---|
| 85 | DATA_BLOB *pac_data_blob,
|
|---|
| 86 | krb5_context context,
|
|---|
| 87 | krb5_keyblock *service_keyblock,
|
|---|
| 88 | krb5_const_principal client_principal,
|
|---|
| 89 | time_t tgs_authtime,
|
|---|
| 90 | struct PAC_DATA **pac_data_out);
|
|---|
| 91 | void smb_krb5_checksum_from_pac_sig(krb5_checksum *cksum,
|
|---|
| 92 | struct PAC_SIGNATURE_DATA *sig);
|
|---|
| 93 | krb5_error_code smb_krb5_verify_checksum(krb5_context context,
|
|---|
| 94 | const krb5_keyblock *keyblock,
|
|---|
| 95 | krb5_keyusage usage,
|
|---|
| 96 | krb5_checksum *cksum,
|
|---|
| 97 | uint8 *data,
|
|---|
| 98 | size_t length);
|
|---|
| 99 | time_t get_authtime_from_tkt(krb5_ticket *tkt);
|
|---|
| 100 | krb5_error_code smb_krb5_get_keyinfo_from_ap_req(krb5_context context,
|
|---|
| 101 | const krb5_data *inbuf,
|
|---|
| 102 | krb5_kvno *kvno,
|
|---|
| 103 | krb5_enctype *enctype);
|
|---|
| 104 | krb5_error_code krb5_rd_req_return_keyblock_from_keytab(krb5_context context,
|
|---|
| 105 | krb5_auth_context *auth_context,
|
|---|
| 106 | const krb5_data *inbuf,
|
|---|
| 107 | krb5_const_principal server,
|
|---|
| 108 | krb5_keytab keytab,
|
|---|
| 109 | krb5_flags *ap_req_options,
|
|---|
| 110 | krb5_ticket **ticket,
|
|---|
| 111 | krb5_keyblock **keyblock);
|
|---|
| 112 | krb5_error_code smb_krb5_parse_name_norealm(krb5_context context,
|
|---|
| 113 | const char *name,
|
|---|
| 114 | krb5_principal *principal);
|
|---|
| 115 | bool smb_krb5_principal_compare_any_realm(krb5_context context,
|
|---|
| 116 | krb5_const_principal princ1,
|
|---|
| 117 | krb5_const_principal princ2);
|
|---|
| 118 | krb5_error_code smb_krb5_renew_ticket(const char *ccache_string, const char *client_string, const char *service_string, time_t *expire_time);
|
|---|
| 119 | krb5_error_code kpasswd_err_to_krb5_err(krb5_error_code res_code);
|
|---|
| 120 | krb5_error_code smb_krb5_gen_netbios_krb5_address(smb_krb5_addresses **kerb_addr);
|
|---|
| 121 | krb5_error_code smb_krb5_free_addresses(krb5_context context, smb_krb5_addresses *addr);
|
|---|
| 122 | NTSTATUS krb5_to_nt_status(krb5_error_code kerberos_error);
|
|---|
| 123 | krb5_error_code nt_status_to_krb5(NTSTATUS nt_status);
|
|---|
| 124 | void smb_krb5_free_error(krb5_context context, krb5_error *krberror);
|
|---|
| 125 | krb5_error_code handle_krberror_packet(krb5_context context,
|
|---|
| 126 | krb5_data *packet);
|
|---|
| 127 |
|
|---|
| 128 | void smb_krb5_get_init_creds_opt_free(krb5_context context,
|
|---|
| 129 | krb5_get_init_creds_opt *opt);
|
|---|
| 130 | krb5_error_code smb_krb5_get_init_creds_opt_alloc(krb5_context context,
|
|---|
| 131 | krb5_get_init_creds_opt **opt);
|
|---|
| 132 | krb5_error_code smb_krb5_mk_error(krb5_context context,
|
|---|
| 133 | krb5_error_code error_code,
|
|---|
| 134 | const krb5_principal server,
|
|---|
| 135 | krb5_data *reply);
|
|---|
| 136 | krb5_enctype smb_get_enctype_from_kt_entry(krb5_keytab_entry *kt_entry);
|
|---|
| 137 | krb5_error_code smb_krb5_enctype_to_string(krb5_context context,
|
|---|
| 138 | krb5_enctype enctype,
|
|---|
| 139 | char **etype_s);
|
|---|
| 140 | krb5_error_code smb_krb5_open_keytab(krb5_context context,
|
|---|
| 141 | const char *keytab_name,
|
|---|
| 142 | bool write_access,
|
|---|
| 143 | krb5_keytab *keytab);
|
|---|
| 144 | krb5_error_code smb_krb5_keytab_name(TALLOC_CTX *mem_ctx,
|
|---|
| 145 | krb5_context context,
|
|---|
| 146 | krb5_keytab keytab,
|
|---|
| 147 | const char **keytab_name);
|
|---|
| 148 | krb5_error_code smb_krb5_get_credentials(krb5_context context,
|
|---|
| 149 | krb5_ccache ccache,
|
|---|
| 150 | krb5_principal me,
|
|---|
| 151 | krb5_principal server,
|
|---|
| 152 | krb5_principal impersonate_princ,
|
|---|
| 153 | krb5_creds **out_creds);
|
|---|
| 154 | krb5_error_code smb_krb5_get_creds(const char *server_s,
|
|---|
| 155 | time_t time_offset,
|
|---|
| 156 | const char *cc,
|
|---|
| 157 | const char *impersonate_princ_s,
|
|---|
| 158 | krb5_creds **creds_p);
|
|---|
| 159 | char *smb_krb5_principal_get_realm(krb5_context context,
|
|---|
| 160 | krb5_principal principal);
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 | #endif /* HAVE_KRB5 */
|
|---|
| 164 |
|
|---|
| 165 | int cli_krb5_get_ticket(TALLOC_CTX *mem_ctx,
|
|---|
| 166 | const char *principal, time_t time_offset,
|
|---|
| 167 | DATA_BLOB *ticket, DATA_BLOB *session_key_krb5,
|
|---|
| 168 | uint32_t extra_ap_opts, const char *ccname,
|
|---|
| 169 | time_t *tgs_expire,
|
|---|
| 170 | const char *impersonate_princ_s);
|
|---|
| 171 |
|
|---|
| 172 | bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx,
|
|---|
| 173 | DATA_BLOB *edata,
|
|---|
| 174 | DATA_BLOB *edata_out);
|
|---|
| 175 | bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data);
|
|---|
| 176 |
|
|---|
| 177 | #endif /* _INCLUDE_KRB5_PROTOS_H_ */
|
|---|