cc02aee27f5fe48612d7866c66d9ad92ca3d320a
[idra/samba.git] / source4 / auth / kerberos / kerberos.h
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    
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.
11    
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.
16    
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/>.
19 */
20
21 #ifndef _AUTH_KERBEROS_H_
22 #define _AUTH_KERBEROS_H_
23
24 #if defined(HAVE_KRB5)
25
26 #include "system/kerberos.h"
27 #include "auth/kerberos/krb5_init_context.h"
28 #include "librpc/gen_ndr/krb5pac.h"
29 #include "lib/krb5_wrap/krb5_samba.h"
30
31 struct auth_user_info_dc;
32 struct cli_credentials;
33
34 struct ccache_container {
35         struct smb_krb5_context *smb_krb5_context;
36         krb5_ccache ccache;
37 };
38
39 struct keytab_container {
40         struct smb_krb5_context *smb_krb5_context;
41         krb5_keytab keytab;
42 };
43
44 /* not really ASN.1, but RFC 1964 */
45 #define TOK_ID_KRB_AP_REQ       ((const uint8_t *)"\x01\x00")
46 #define TOK_ID_KRB_AP_REP       ((const uint8_t *)"\x02\x00")
47 #define TOK_ID_KRB_ERROR        ((const uint8_t *)"\x03\x00")
48 #define TOK_ID_GSS_GETMIC       ((const uint8_t *)"\x01\x01")
49 #define TOK_ID_GSS_WRAP         ((const uint8_t *)"\x02\x01")
50
51 #ifdef HAVE_KRB5_KEYBLOCK_KEYVALUE
52 #define KRB5_KEY_TYPE(k)        ((k)->keytype)
53 #define KRB5_KEY_LENGTH(k)      ((k)->keyvalue.length)
54 #define KRB5_KEY_DATA(k)        ((k)->keyvalue.data)
55 #else
56 #define KRB5_KEY_TYPE(k)        ((k)->enctype)
57 #define KRB5_KEY_LENGTH(k)      ((k)->length)
58 #define KRB5_KEY_DATA(k)        ((k)->contents)
59 #endif /* HAVE_KRB5_KEYBLOCK_KEYVALUE */
60
61 #define ENC_ALL_TYPES (ENC_CRC32 | ENC_RSA_MD5 | ENC_RC4_HMAC_MD5 |     \
62                        ENC_HMAC_SHA1_96_AES128 | ENC_HMAC_SHA1_96_AES256)
63
64 #ifndef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES
65 krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc);
66 #endif
67
68 #if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
69 krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock *keyblock);
70 #endif
71
72 #if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING) && !defined(HAVE_KRB5_PRINC_COMPONENT)
73 const krb5_data *krb5_princ_component(krb5_context context, krb5_principal principal, int i );
74 #endif
75
76 /* Samba wrapper function for krb5 functionality. */
77 krb5_error_code kerberos_kinit_password_cc(krb5_context ctx, krb5_ccache cc,
78                                            krb5_principal principal, const char *password,
79                                            krb5_principal impersonate_principal,
80                                            const char *self_service,
81                                            const char *target_service,
82                                            krb5_get_init_creds_opt *krb_options,
83                                            time_t *expire_time, time_t *kdc_time);
84 krb5_error_code kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc,
85                                            krb5_principal principal, krb5_keyblock *keyblock,
86                                            const char *target_service,
87                                            krb5_get_init_creds_opt *krb_options,
88                                            time_t *expire_time, time_t *kdc_time);
89 NTSTATUS kerberos_pac_logon_info(TALLOC_CTX *mem_ctx,
90                                  DATA_BLOB blob,
91                                  krb5_context context,
92                                  const krb5_keyblock *krbtgt_keyblock,
93                                  const krb5_keyblock *service_keyblock,
94                                  krb5_const_principal client_principal,
95                                  time_t tgs_authtime,
96                                  struct PAC_LOGON_INFO **logon_info);
97  krb5_error_code kerberos_encode_pac(TALLOC_CTX *mem_ctx,
98                                     struct PAC_DATA *pac_data,
99                                     krb5_context context,
100                                     const krb5_keyblock *krbtgt_keyblock,
101                                     const krb5_keyblock *service_keyblock,
102                                     DATA_BLOB *pac);
103  krb5_error_code kerberos_create_pac(TALLOC_CTX *mem_ctx,
104                                      struct auth_user_info_dc *user_info_dc,
105                                      krb5_context context,
106                                      const krb5_keyblock *krbtgt_keyblock,
107                                      const krb5_keyblock *service_keyblock,
108                                      krb5_principal client_principal,
109                                      time_t tgs_authtime,
110                                      DATA_BLOB *pac);
111
112 #include "auth/kerberos/proto.h"
113
114 #endif /* HAVE_KRB5 */
115
116 #endif /* _AUTH_KERBEROS_H_ */