1 .\" Copyright (c) 2001 - 2005 Kungliga Tekniska Högskolan
2 .\" (Royal Institute of Technology, Stockholm, Sweden).
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the Institute nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" $Heimdal: krb5_keytab.3 22071 2007-11-14 20:04:50Z lha $
33 .\" $NetBSD: krb5_keytab.3,v 1.9 2008/03/22 08:37:14 mlelstv Exp $
40 .Nm krb5_keytab_entry ,
42 .Nm krb5_kt_add_entry ,
45 .Nm krb5_kt_copy_entry_contents ,
47 .Nm krb5_kt_default_modify_name ,
48 .Nm krb5_kt_default_name ,
49 .Nm krb5_kt_end_seq_get ,
50 .Nm krb5_kt_free_entry ,
51 .Nm krb5_kt_get_entry ,
52 .Nm krb5_kt_get_name ,
53 .Nm krb5_kt_get_type ,
54 .Nm krb5_kt_next_entry ,
55 .Nm krb5_kt_read_service_key ,
56 .Nm krb5_kt_register ,
57 .Nm krb5_kt_remove_entry ,
59 .Nm krb5_kt_start_seq_get
60 .Nd manage keytab (key storage) files
62 Kerberos 5 Library (libkrb5, -lkrb5)
68 .Fa "krb5_context context"
70 .Fa "krb5_keytab_entry *entry"
74 .Fa "krb5_context context"
79 .Fa "krb5_context context"
80 .Fa "krb5_keytab_entry *entry"
81 .Fa "krb5_const_principal principal"
83 .Fa "krb5_enctype enctype"
86 .Fo krb5_kt_copy_entry_contents
87 .Fa "krb5_context context"
88 .Fa "const krb5_keytab_entry *in"
89 .Fa "krb5_keytab_entry *out"
93 .Fa "krb5_context context"
97 .Fo krb5_kt_default_modify_name
98 .Fa "krb5_context context"
100 .Fa "size_t namesize"
103 .Fo krb5_kt_default_name
104 .Fa "krb5_context context"
106 .Fa "size_t namesize"
109 .Fo krb5_kt_end_seq_get
110 .Fa "krb5_context context"
112 .Fa "krb5_kt_cursor *cursor"
115 .Fo krb5_kt_free_entry
116 .Fa "krb5_context context"
117 .Fa "krb5_keytab_entry *entry"
120 .Fo krb5_kt_get_entry
121 .Fa "krb5_context context"
123 .Fa "krb5_const_principal principal"
125 .Fa "krb5_enctype enctype"
126 .Fa "krb5_keytab_entry *entry"
130 .Fa "krb5_context context"
131 .Fa "krb5_keytab keytab"
133 .Fa "size_t namesize"
137 .Fa "krb5_context context"
138 .Fa "krb5_keytab keytab"
140 .Fa "size_t prefixsize"
143 .Fo krb5_kt_next_entry
144 .Fa "krb5_context context"
146 .Fa "krb5_keytab_entry *entry"
147 .Fa "krb5_kt_cursor *cursor"
150 .Fo krb5_kt_read_service_key
151 .Fa "krb5_context context"
152 .Fa "krb5_pointer keyprocarg"
153 .Fa "krb5_principal principal"
155 .Fa "krb5_enctype enctype"
156 .Fa "krb5_keyblock **key"
160 .Fa "krb5_context context"
161 .Fa "const krb5_kt_ops *ops"
164 .Fo krb5_kt_remove_entry
165 .Fa "krb5_context context"
167 .Fa "krb5_keytab_entry *entry"
171 .Fa "krb5_context context"
172 .Fa "const char *name"
173 .Fa "krb5_keytab *id"
176 .Fo krb5_kt_start_seq_get
177 .Fa "krb5_context context"
179 .Fa "krb5_kt_cursor *cursor"
182 A keytab name is on the form
186 part is specific to each keytab-type.
188 When a keytab-name is resolved, the type is matched with an internal
189 list of keytab types. If there is no matching keytab type,
190 the default keytab is used. The current default type is
192 The default value can be changed in the configuration file
194 by setting the variable
195 .Li [defaults]default_keytab_name .
197 The keytab types that are implemented in Heimdal
201 store the keytab in a file, the type's name is
203 The residual part is a filename.
204 For compatibility with other Kerberos implemtation
210 has the same format as
213 have a format that is compatible with older versions of MIT kerberos
214 and SUN's Java based installation. They store a truncted kvno, so
215 when the knvo excess 255, they are truncted in this format.
217 store the keytab in a
220 .Pa /usr/afs/etc/KeyFile ) ,
223 The residual part is a filename.
225 the keytab is a Kerberos 4
227 that is on-the-fly converted to a keytab. The type's name is
229 The residual part is a filename.
231 The keytab is stored in a memory segment. This allows sensitive and/or
232 temporary data not to be stored on disk. The type's name is
236 keytab is referenced counted by and opened by the residual name, so two
237 handles can point to the same memory area.
238 When the last user closes the entry, it disappears.
241 .Nm krb5_keytab_entry
242 holds all data for an entry in a keytab file, like principal name,
243 key-type, key, key-version number, etc.
245 holds the current position that is used when iterating through a
247 .Fn krb5_kt_start_seq_get ,
248 .Fn krb5_kt_next_entry ,
250 .Fn krb5_kt_end_seq_get .
253 contains the different operations that can be done to a keytab. This
254 structure is normally only used when doing a new keytab-type
258 is the equivalent of an
260 on keytab. Resolve the keytab name in
264 Returns 0 or an error. The opposite of
270 frees all resources allocated to the keytab, even on failure.
271 Returns 0 or an error.
276 to the default keytab.
277 Returns 0 or an error.
279 .Fn krb5_kt_default_modify_name
280 copies the name of the default modify keytab into
282 Return 0 or KRB5_CONFIG_NOTENUFSPACE if
286 .Fn krb5_kt_default_name
287 copies the name of the default keytab into
289 Return 0 or KRB5_CONFIG_NOTENUFSPACE if
293 .Fn krb5_kt_add_entry
299 is returned if the keytab is a readonly keytab.
302 compares the passed in
314 might be 0 which acts as a wildcard. Return TRUE if they compare the
315 same, FALSE otherwise.
317 .Fn krb5_kt_copy_entry_contents
318 copies the contents of
322 Returns 0 or an error.
325 retrieves the name of the keytab
330 Returns 0 or an error.
333 retrieves the type of the keytab
335 and store the prefix/name for type of the keytab into
338 The prefix will have the maximum length of
339 .Dv KRB5_KT_PREFIX_MAX_LEN
340 (including terminating
342 Returns 0 or an error.
344 .Fn krb5_kt_free_entry
345 frees the contents of
348 .Fn krb5_kt_start_seq_get
351 to point at the beginning of
353 Returns 0 or an error.
355 .Fn krb5_kt_next_entry
356 gets the next entry from
362 On success the returne entry must be freed with
363 .Fn krb5_kt_free_entry .
364 Returns 0 or an error.
366 .Fn krb5_kt_end_seq_get
367 releases all resources associated with
370 .Fn krb5_kt_get_entry
371 retrieves the keytab entry for
379 When comparing an entry in the keytab to determine a match, the
382 is used, so the wildcard rules applies to the argument of
383 .Fn krb5_kt_get_entry
385 On success the returne entry must be freed with
386 .Fn krb5_kt_free_entry .
387 Returns 0 or an error.
389 .Fn krb5_kt_read_service_key
390 reads the key identified by
396 (the system default keytab if
401 is the same argument as to
404 .Fn krb5_kt_resolve .
407 will be used, so the same wildcard rules applies
409 .Fn krb5_kt_read_service_key .
410 On success the returned key must be freed with
411 .Fa krb5_free_keyblock .
412 Returns 0 or an error.
414 .Fn krb5_kt_remove_entry
419 When comparing an entry in the keytab to determine a match, the
422 is use, so the wildcard rules applies to the argument of
423 .Fn krb5_kt_remove_entry .
426 if not entry matched or another error.
429 registers a new keytab type
431 Returns 0 or an error.
433 This is a minimalistic version of
438 main (int argc, char **argv)
440 krb5_context context;
442 krb5_kt_cursor cursor;
443 krb5_keytab_entry entry;
447 if (krb5_init_context (&context) != 0)
448 errx(1, "krb5_context");
450 ret = krb5_kt_default (context, &keytab);
452 krb5_err(context, 1, ret, "krb5_kt_default");
454 ret = krb5_kt_start_seq_get(context, keytab, &cursor);
456 krb5_err(context, 1, ret, "krb5_kt_start_seq_get");
457 while((ret = krb5_kt_next_entry(context, keytab, &entry, &cursor)) == 0){
458 krb5_unparse_name_short(context, entry.principal, &principal);
459 printf("principal: %s\\n", principal);
461 krb5_kt_free_entry(context, &entry);
463 ret = krb5_kt_end_seq_get(context, keytab, &cursor);
465 krb5_err(context, 1, ret, "krb5_kt_end_seq_get");
466 ret = krb5_kt_close(context, keytab);
468 krb5_err(context, 1, ret, "krb5_kt_close");
469 krb5_free_context(context);
474 Heimdal stored the ticket flags in machine bit-field order before
475 Heimdal 0.7. The behavior is possible to change in with the option
476 .Li [libdefaults]fcc-mit-ticketflags .
477 Heimdal 0.7 also code to detech that ticket flags was in the wrong
478 order and correct them. This matters when doing delegation in GSS-API
479 because the client code looks at the flag to determin if it is possible
480 to do delegation if the user requested it.