1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/krb5/krb/in_tkt_sky.c */
4 * Copyright 1990,1991, 2008 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. Furthermore if you modify this software you must label
20 * your software as modified software and not distribute it in such a
21 * fashion that it might be confused with the original M.I.T. software.
22 * M.I.T. makes no representations about the suitability of
23 * this software for any purpose. It is provided "as is" without express
24 * or implied warranty.
29 /* A krb5_gic_get_as_key_fct shim for copying a caller-provided keyblock into
31 static krb5_error_code
32 get_as_key_skey(krb5_context context, krb5_principal client,
33 krb5_enctype etype, krb5_prompter_fct prompter,
34 void *prompter_data, krb5_data *salt, krb5_data *params,
35 krb5_keyblock *as_key, void *gak_data)
37 const krb5_keyblock *key = gak_data;
39 if (!krb5_c_valid_enctype(etype))
40 return(KRB5_PROG_ETYPE_NOSUPP);
42 krb5_free_keyblock_contents(context, as_key);
43 return krb5int_c_copy_keyblock_contents(context, key, as_key);
47 Similar to krb5_get_in_tkt_with_password.
49 Attempts to get an initial ticket for creds->client to use server
50 creds->server, (realm is taken from creds->client), with options
51 options, and using creds->times.starttime, creds->times.endtime,
52 creds->times.renew_till as from, till, and rtime.
53 creds->times.renew_till is ignored unless the RENEWABLE option is requested.
55 If addrs is non-NULL, it is used for the addresses requested. If it is
56 null, the system standard addresses are used.
58 If keyblock is NULL, an appropriate key for creds->client is retrieved
59 from the system key store (e.g. /etc/srvtab). If keyblock is non-NULL,
60 it is used as the decryption key.
62 A succesful call will place the ticket in the credentials cache ccache.
64 returns system errors, encryption errors
67 krb5_error_code KRB5_CALLCONV
68 krb5_get_in_tkt_with_skey(krb5_context context, krb5_flags options,
69 krb5_address *const *addrs, krb5_enctype *ktypes,
70 krb5_preauthtype *pre_auth_types,
71 const krb5_keyblock *key, krb5_ccache ccache,
72 krb5_creds *creds, krb5_kdc_rep **ret_as_reply)
74 krb5_error_code retval;
76 krb5_principal server_princ, client_princ;
78 krb5_get_init_creds_opt *opts = NULL;
82 return krb5_get_in_tkt_with_keytab(context, options, addrs, ktypes,
83 pre_auth_types, NULL, ccache,
86 #endif /* LEAN_CLIENT */
88 retval = krb5int_populate_gic_opt(context, &opts, options, addrs, ktypes,
89 pre_auth_types, creds);
92 retval = krb5_unparse_name(context, creds->server, &server);
94 krb5_get_init_creds_opt_free(context, opts);
97 server_princ = creds->server;
98 client_princ = creds->client;
99 retval = krb5int_get_init_creds(context, creds, creds->client,
100 krb5_prompter_posix, NULL, 0, server, opts,
101 get_as_key_skey, (void *) key, &use_master,
103 krb5_free_unparsed_name(context, server);
104 krb5_get_init_creds_opt_free(context, opts);
107 krb5_free_principal( context, creds->server);
108 krb5_free_principal( context, creds->client);
109 creds->client = client_princ;
110 creds->server = server_princ;
111 /* store it in the ccache! */
113 retval = krb5_cc_store_cred(context, ccache, creds);