2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
12 #include "afs/param.h"
14 #include <afs/param.h>
21 #include "afs/sysincludes.h"
22 #include "afsincludes.h"
24 #include "afs/pthread_glock.h"
28 #include "afs/cellconfig.h"
31 #include "afs/pthread_glock.h"
32 #else /* defined(UKERNEL) */
34 #include <afs/pthread_glock.h>
35 #include <sys/types.h>
41 #include <netinet/in.h>
47 #include "cellconfig.h"
50 #endif /* defined(UKERNEL) */
52 /* return a null security object if nothing else can be done */
54 QuickAuth(astr, aindex)
55 struct rx_securityClass **astr;
58 register struct rx_securityClass *tc;
59 tc = rxnull_NewClientSecurityObject();
66 /* Return an appropriate security class and index */
68 afsconf_ServerAuth(adir, astr, aindex)
69 register struct afsconf_dir *adir;
70 struct rx_securityClass **astr;
73 register struct rx_securityClass *tclass;
76 tclass = (struct rx_securityClass *)
77 rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL);
80 *aindex = 2; /* kerberos security index */
88 #endif /* !defined(UKERNEL) */
91 GenericAuth(adir, astr, aindex, enclevel)
92 struct afsconf_dir *adir;
93 struct rx_securityClass **astr;
98 struct ktc_encryptionKey key, session;
99 struct rx_securityClass *tclass;
102 register afs_int32 code;
104 /* first, find the right key and kvno to use */
105 code = afsconf_GetLatestKey(adir, &kvno, &key);
107 return QuickAuth(astr, aindex);
110 /* next create random session key, using key for seed to good random */
111 des_init_random_number_generator(&key);
112 code = des_random_key(&session);
114 return QuickAuth(astr, aindex);
117 /* now create the actual ticket */
118 ticketLen = sizeof(tbuffer);
119 memset(tbuffer, '\0', sizeof(tbuffer));
121 tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0,
122 0xffffffff, &session, 0, "afs", "");
123 /* parms were buffer, ticketlen, key to seal ticket with, principal
124 * name, instance and cell, start time, end time, session key to seal
125 * in ticket, inet host, server name and server instance */
127 return QuickAuth(astr, aindex);
130 /* Next, we have ticket, kvno and session key, authenticate the connection.
131 * We use a magic # instead of a constant because of basic compilation
132 * order when compiling the system from scratch (rx/rxkad.h isn't installed
134 tclass = (struct rx_securityClass *)
135 rxkad_NewClientSecurityObject(enclevel, &session, kvno, ticketLen,
138 *aindex = 2; /* kerberos security index */
142 /* build a fake ticket for 'afs' using keys from adir, returning an
143 * appropriate security class and index
146 afsconf_ClientAuth(struct afsconf_dir * adir, struct rx_securityClass ** astr,
152 rc = GenericAuth(adir, astr, aindex, rxkad_clear);
157 /* build a fake ticket for 'afs' using keys from adir, returning an
158 * appropriate security class and index. This one, unlike the above,
159 * tells rxkad to encrypt the data, too.
162 afsconf_ClientAuthSecure(adir, astr, aindex)
163 struct afsconf_dir *adir;
164 struct rx_securityClass **astr;
170 rc = GenericAuth(adir, astr, aindex, rxkad_crypt);