auth/credentials: Support match-by-key in cli_credentials_get_server_gss_creds()
[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 #include "lib/krb5_wrap/gss_samba.h"
31
32 struct auth_user_info_dc;
33 struct cli_credentials;
34
35 struct ccache_container {
36         struct smb_krb5_context *smb_krb5_context;
37         krb5_ccache ccache;
38 };
39
40 struct keytab_container {
41         struct smb_krb5_context *smb_krb5_context;
42         krb5_keytab keytab;
43         bool password_based;
44 };
45
46 /* not really ASN.1, but RFC 1964 */
47 #define TOK_ID_KRB_AP_REQ       ((const uint8_t *)"\x01\x00")
48 #define TOK_ID_KRB_AP_REP       ((const uint8_t *)"\x02\x00")
49 #define TOK_ID_KRB_ERROR        ((const uint8_t *)"\x03\x00")
50 #define TOK_ID_GSS_GETMIC       ((const uint8_t *)"\x01\x01")
51 #define TOK_ID_GSS_WRAP         ((const uint8_t *)"\x02\x01")
52
53 #ifdef HAVE_KRB5_KEYBLOCK_KEYVALUE
54 #define KRB5_KEY_TYPE(k)        ((k)->keytype)
55 #define KRB5_KEY_LENGTH(k)      ((k)->keyvalue.length)
56 #define KRB5_KEY_DATA(k)        ((k)->keyvalue.data)
57 #else
58 #define KRB5_KEY_TYPE(k)        ((k)->enctype)
59 #define KRB5_KEY_LENGTH(k)      ((k)->length)
60 #define KRB5_KEY_DATA(k)        ((k)->contents)
61 #endif /* HAVE_KRB5_KEYBLOCK_KEYVALUE */
62
63 #define ENC_ALL_TYPES (ENC_CRC32 | ENC_RSA_MD5 | ENC_RC4_HMAC_MD5 |     \
64                        ENC_HMAC_SHA1_96_AES128 | ENC_HMAC_SHA1_96_AES256)
65
66 #ifndef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES
67 krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc);
68 #endif
69
70 #if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
71 krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock *keyblock);
72 #endif
73
74 #if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING) && !defined(HAVE_KRB5_PRINC_COMPONENT)
75 const krb5_data *krb5_princ_component(krb5_context context, krb5_principal principal, int i );
76 #endif
77
78 #ifndef krb5_princ_size
79 #if defined(HAVE_KRB5_PRINCIPAL_GET_NUM_COMP)
80 #define krb5_princ_size krb5_principal_get_num_comp
81 #else
82 #error krb5_princ_size unavailable
83 #endif
84 #endif
85
86 /* Samba wrapper function for krb5 functionality. */
87  krb5_error_code kerberos_encode_pac(TALLOC_CTX *mem_ctx,
88                                     struct PAC_DATA *pac_data,
89                                     krb5_context context,
90                                     const krb5_keyblock *krbtgt_keyblock,
91                                     const krb5_keyblock *service_keyblock,
92                                     DATA_BLOB *pac);
93  krb5_error_code kerberos_create_pac(TALLOC_CTX *mem_ctx,
94                                      struct auth_user_info_dc *user_info_dc,
95                                      krb5_context context,
96                                      const krb5_keyblock *krbtgt_keyblock,
97                                      const krb5_keyblock *service_keyblock,
98                                      krb5_principal client_principal,
99                                      time_t tgs_authtime,
100                                      DATA_BLOB *pac);
101
102 #include "auth/kerberos/proto.h"
103
104 #endif /* HAVE_KRB5 */
105
106 #endif /* _AUTH_KERBEROS_H_ */