Deleted Added
sdiff udiff text old ( 90926 ) new ( 120945 )
full compact
1/*
2 * Copyright (c) 1997 - 2002 Kungliga Tekniska H�gskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include "krb5_locl.h"
35RCSID("$Id: convert_creds.c,v 1.26 2003/03/18 03:11:16 lha Exp $");
36
37#include "krb5-v4compat.h"
38
39static krb5_error_code
40check_ticket_flags(TicketFlags f)
41{
42 return 0; /* maybe add some more tests here? */
43}
44
45/* include this here, to avoid dependencies on libkrb */
46
47static const int _tkt_lifetimes[TKTLIFENUMFIXED] = {
48 38400, 41055, 43894, 46929, 50174, 53643, 57352, 61318,
49 65558, 70091, 74937, 80119, 85658, 91581, 97914, 104684,
50 111922, 119661, 127935, 136781, 146239, 156350, 167161, 178720,
51 191077, 204289, 218415, 233517, 249664, 266926, 285383, 305116,
52 326213, 348769, 372885, 398668, 426234, 455705, 487215, 520904,
53 556921, 595430, 636601, 680618, 727680, 777995, 831789, 889303,
54 950794, 1016537, 1086825, 1161973, 1242318, 1328218, 1420057, 1518247,
55 1623226, 1735464, 1855462, 1983758, 2120925, 2267576, 2424367, 2592000
56};
57
58int
59_krb5_krb_time_to_life(time_t start, time_t end)
60{
61 int i;
62 time_t life = end - start;
63
64 if (life > MAXTKTLIFETIME || life <= 0)
65 return 0;
66#if 0
67 if (krb_no_long_lifetimes)

--- 6 unchanged lines hidden (view full) ---

74 return (life + 5*60 - 1)/(5*60);
75 for (i=0; i<TKTLIFENUMFIXED; i++)
76 if (life <= _tkt_lifetimes[i])
77 return i + TKTLIFEMINFIXED;
78 return 0;
79
80}
81
82time_t
83_krb5_krb_life_to_time(int start, int life_)
84{
85 unsigned char life = (unsigned char) life_;
86
87#if 0
88 if (krb_no_long_lifetimes)
89 return start + life*5*60;
90#endif
91
92 if (life == TKTLIFENOEXPIRE)
93 return NEVERDATE;
94 if (life < TKTLIFEMINFIXED)
95 return start + life*5*60;
96 if (life > TKTLIFEMAXFIXED)
97 return start + MAXTKTLIFETIME;
98 return start + _tkt_lifetimes[life - TKTLIFEMINFIXED];
99}
100
101
102/* Convert the v5 credentials in `in_cred' to v4-dito in `v4creds'.
103 * This is done by sending them to the 524 function in the KDC. If
104 * `in_cred' doesn't contain a DES session key, then a new one is
105 * gotten from the KDC and stored in the cred cache `ccache'.
106 */
107
108krb5_error_code
109krb524_convert_creds_kdc(krb5_context context,

--- 54 unchanged lines hidden (view full) ---

164 ret = krb5_524_conv_principal(context,
165 v5_creds->server,
166 v4creds->service,
167 v4creds->instance,
168 v4creds->realm);
169 if(ret)
170 goto out;
171 v4creds->issue_date = v5_creds->times.starttime;
172 v4creds->lifetime = _krb5_krb_time_to_life(v4creds->issue_date,
173 v5_creds->times.endtime);
174 ret = krb5_524_conv_principal(context, v5_creds->client,
175 v4creds->pname,
176 v4creds->pinst,
177 realm);
178 if(ret)
179 goto out;
180 memcpy(v4creds->session, v5_creds->session.keyvalue.data, 8);
181 } else {

--- 55 unchanged lines hidden ---