2 * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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
36 RCSID("$Id: kdc_reply.c,v 1.12.2.2 2000/12/04 14:34:28 assar Exp $");
38 static int little_endian; /* XXX ugly */
41 kdc_reply_cred(KTEXT cip, CREDENTIALS *cred)
43 unsigned char *p = cip->dat;
45 memcpy(cred->session, p, 8);
48 if(p + strlen((char*)p) > cip->dat + cip->length)
50 p += krb_get_string(p, cred->service, sizeof(cred->service));
52 if(p + strlen((char*)p) > cip->dat + cip->length)
54 p += krb_get_string(p, cred->instance, sizeof(cred->instance));
56 if(p + strlen((char*)p) > cip->dat + cip->length)
58 p += krb_get_string(p, cred->realm, sizeof(cred->realm));
60 if(p + 3 > cip->dat + cip->length)
62 cred->lifetime = *p++;
64 cred->ticket_st.length = *p++;
66 if(p + cred->ticket_st.length + 4 > cip->dat + cip->length)
68 memcpy(cred->ticket_st.dat, p, cred->ticket_st.length);
69 p += cred->ticket_st.length;
71 p += krb_get_int(p, (u_int32_t *)&cred->issue_date, 4, little_endian);
77 kdc_reply_cipher(KTEXT reply, KTEXT cip)
95 if (pvno != KRB_PROT_VERSION )
99 little_endian = type & 1;
103 if(type == AUTH_MSG_ERR_REPLY){
105 /* skip these fields */
106 p += strlen((char*)p) + 1; /* name */
107 p += strlen((char*)p) + 1; /* instance */
108 p += strlen((char*)p) + 1; /* realm */
110 p += krb_get_int(p, &code, 4, little_endian);
112 code = KFAILURE; /* things will go bad otherwise */
115 if(type != AUTH_MSG_KDC_REPLY)
119 aname, sizeof(aname),
121 realm, sizeof(realm));
122 p += krb_get_int(p, &kdc_time, 4, little_endian);
123 p++; /* number of tickets */
124 p += krb_get_int(p, &exp_date, 4, little_endian);
125 p++; /* master key version number */
126 p += krb_get_int(p, &clen, 2, little_endian);
127 if (reply->length - (p - reply->dat) < clen)
131 memcpy(cip->dat, p, clen);