xref: /illumos-gate/usr/src/lib/gss_mechs/mech_krb5/krb5/keytab/file/ktfile.h (revision edd580643f2cf1434e252cd7779e83182ea84945)
1 /*
2  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  *
5  * lib/krb5/keytab/file/ktfile.h
6  *
7  * Copyright 1990 by the Massachusetts Institute of Technology.
8  * All Rights Reserved.
9  *
10  * Export of this software from the United States of America may
11  *   require a specific license from the United States Government.
12  *   It is the responsibility of any person or organization contemplating
13  *   export to obtain such a license before exporting.
14  *
15  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
16  * distribute this software and its documentation for any purpose and
17  * without fee is hereby granted, provided that the above copyright
18  * notice appear in all copies and that both that copyright notice and
19  * this permission notice appear in supporting documentation, and that
20  * the name of M.I.T. not be used in advertising or publicity pertaining
21  * to distribution of the software without specific, written prior
22  * permission.  Furthermore if you modify this software you must label
23  * your software as modified software and not distribute it in such a
24  * fashion that it might be confused with the original M.I.T. software.
25  * M.I.T. makes no representations about the suitability of
26  * this software for any purpose.  It is provided "as is" without express
27  * or implied warranty.
28  *
29  *
30  * This header file contains information needed by internal routines
31  * of the file-based ticket cache implementation.
32  */
33 
34 #ifndef	_KRB5_KTFILE
35 #define	_KRB5_KTFILE
36 
37 #pragma ident	"%Z%%M%	%I%	%E% SMI"
38 
39 #include <stdio.h>
40 #include <sys/mman.h>
41 
42 /*
43  * Constants
44  */
45 #define IGNORE_VNO 0
46 #define IGNORE_ENCTYPE 0
47 
48 #define KRB5_KT_VNO_1	0x0501	/* krb v5, keytab version 1 (DCE compat) */
49 #define KRB5_KT_VNO	0x0502	/* krb v5, keytab version 2 (standard)  */
50 
51 #define KRB5_KT_DEFAULT_VNO KRB5_KT_VNO
52 
53 /*
54  * Types
55  */
56 typedef struct _krb5_ktfile_data {
57     char *name;			/* Name of the file */
58     char *datap;		/* ptr to the file data */
59     int	version;		/* Version number of keytab */
60     offset_t offset;		/* current offset into the data buffer */
61     size_t filesize;		/* size of original file */
62     size_t bufsize;		/* total size of data buffer */
63     uchar_t writable:1;		/* Was the file opened for writing? */
64 } krb5_ktfile_data;
65 
66 /*
67  * Macros
68  */
69 #define KTPRIVATE(id) ((krb5_ktfile_data *)(id)->data)
70 #define KTFILENAME(id) (((krb5_ktfile_data *)(id)->data)->name)
71 /*
72 #define KTFILEP(id) (((krb5_ktfile_data *)(id)->data)->openf)
73 */
74 #define	KTDATAP(id) (((krb5_ktfile_data *)(id)->data)->datap)
75 #define KTVERSION(id) (((krb5_ktfile_data *)(id)->data)->version)
76 #define	KTOFFSET(id) (((krb5_ktfile_data *)(id)->data)->offset)
77 
78 extern struct _krb5_kt_ops krb5_ktf_ops;
79 extern struct _krb5_kt_ops krb5_ktf_writable_ops;
80 
81 krb5_error_code KRB5_CALLCONV krb5_ktfile_resolve
82 	(krb5_context,
83 		   const char *,
84 		   krb5_keytab *);
85 
86 krb5_error_code KRB5_CALLCONV krb5_ktfile_wresolve
87 	(krb5_context,
88 		   const char *,
89 		   krb5_keytab *);
90 
91 krb5_error_code KRB5_CALLCONV krb5_ktfile_get_name
92 	(krb5_context,
93 		   krb5_keytab,
94 		   char *,
95 		   int);
96 
97 krb5_error_code KRB5_CALLCONV krb5_ktfile_close
98 	(krb5_context,
99 		   krb5_keytab);
100 
101 krb5_error_code KRB5_CALLCONV krb5_ktfile_get_entry
102 	(krb5_context,
103 		   krb5_keytab,
104 		   krb5_const_principal,
105 		   krb5_kvno,
106 		   krb5_enctype,
107 		   krb5_keytab_entry *);
108 
109 krb5_error_code KRB5_CALLCONV krb5_ktfile_start_seq_get
110 	(krb5_context,
111 		   krb5_keytab,
112 		   krb5_kt_cursor *);
113 
114 krb5_error_code KRB5_CALLCONV krb5_ktfile_get_next
115 	(krb5_context,
116 		   krb5_keytab,
117 		   krb5_keytab_entry *,
118 		   krb5_kt_cursor *);
119 
120 krb5_error_code KRB5_CALLCONV krb5_ktfile_end_get
121 	(krb5_context,
122 		   krb5_keytab,
123 		   krb5_kt_cursor *);
124 
125 /* routines to be included on extended version (write routines) */
126 krb5_error_code KRB5_CALLCONV krb5_ktfile_add
127 	(krb5_context,
128 		   krb5_keytab,
129 		   krb5_keytab_entry *);
130 
131 krb5_error_code KRB5_CALLCONV krb5_ktfile_remove
132 	(krb5_context,
133 		   krb5_keytab,
134 		   krb5_keytab_entry *);
135 
136 krb5_error_code krb5_ktfileint_openr
137 	(krb5_context,
138 		   krb5_keytab);
139 
140 krb5_error_code krb5_ktfileint_openw
141 	(krb5_context,
142 		   krb5_keytab);
143 
144 krb5_error_code krb5_ktfileint_close
145 	(krb5_context,
146 		   krb5_keytab);
147 
148 krb5_error_code krb5_ktfileint_read_entry
149 	(krb5_context,
150 		   krb5_keytab,
151 		   krb5_keytab_entry *);
152 
153 krb5_error_code krb5_ktfileint_write_entry
154 	(krb5_context,
155 		   krb5_keytab,
156 		   krb5_keytab_entry *);
157 
158 krb5_error_code krb5_ktfileint_delete_entry
159 	(krb5_context,
160 		   krb5_keytab,
161                    krb5_int32);
162 
163 krb5_error_code krb5_ktfileint_internal_read_entry
164 	(krb5_context,
165 		   krb5_keytab,
166 		   krb5_keytab_entry *,
167                    krb5_int32 *);
168 
169 krb5_error_code krb5_ktfileint_size_entry
170 	(krb5_context,
171 		   krb5_keytab_entry *,
172                    krb5_int32 *);
173 
174 krb5_error_code krb5_ktfileint_find_slot
175 	(krb5_context,
176 		   krb5_keytab,
177                    krb5_int32 *,
178                    krb5_int32 *);
179 
180 
181 #endif /* _KRB5_KTFILE */
182