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.
28 #include "int-proto.h"
30 /* Copy the caller-provided keyblock into the AS keyblock. */
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,
36 k5_response_items *ritems)
38 const krb5_keyblock *key = gak_data;
40 if (!krb5_c_valid_enctype(etype))
41 return(KRB5_PROG_ETYPE_NOSUPP);
43 krb5_free_keyblock_contents(context, as_key);
44 return krb5int_c_copy_keyblock_contents(context, key, as_key);
48 Similar to krb5_get_in_tkt_with_password.
50 Attempts to get an initial ticket for creds->client to use server
51 creds->server, (realm is taken from creds->client), with options
52 options, and using creds->times.starttime, creds->times.endtime,
53 creds->times.renew_till as from, till, and rtime.
54 creds->times.renew_till is ignored unless the RENEWABLE option is requested.
56 If addrs is non-NULL, it is used for the addresses requested. If it is
57 null, the system standard addresses are used.
59 If keyblock is NULL, an appropriate key for creds->client is retrieved
60 from the system key store (e.g. /etc/srvtab). If keyblock is non-NULL,
61 it is used as the decryption key.
63 A succesful call will place the ticket in the credentials cache ccache.
65 returns system errors, encryption errors
68 krb5_error_code KRB5_CALLCONV
69 krb5_get_in_tkt_with_skey(krb5_context context, krb5_flags options,
70 krb5_address *const *addrs, krb5_enctype *ktypes,
71 krb5_preauthtype *pre_auth_types,
72 const krb5_keyblock *key, krb5_ccache ccache,
73 krb5_creds *creds, krb5_kdc_rep **ret_as_reply)
75 krb5_error_code retval;
77 krb5_principal server_princ, client_princ;
79 krb5_get_init_creds_opt *opts = NULL;
81 retval = k5_populate_gic_opt(context, &opts, options, addrs, ktypes,
82 pre_auth_types, creds);
86 retval = krb5_get_init_creds_opt_set_out_ccache(context, opts, ccache);
92 retval = krb5_get_init_creds_keytab(context, creds, creds->client,
94 creds->times.starttime,
95 NULL /* in_tkt_service */,
99 #endif /* LEAN_CLIENT */
101 retval = krb5_unparse_name(context, creds->server, &server);
104 server_princ = creds->server;
105 client_princ = creds->client;
106 retval = k5_get_init_creds(context, creds, creds->client,
107 krb5_prompter_posix, NULL, 0, server, opts,
108 get_as_key_skey, (void *)key, &use_master,
110 krb5_free_unparsed_name(context, server);
113 krb5_free_principal( context, creds->server);
114 krb5_free_principal( context, creds->client);
115 creds->client = client_princ;
116 creds->server = server_princ;
118 krb5_get_init_creds_opt_free(context, opts);