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>
20 #include "afs/sysincludes.h"
21 #include "afsincludes.h"
23 #include "afs/pthread_glock.h"
27 #include "afs/cellconfig.h"
30 #include "afs/pthread_glock.h"
31 #else /* defined(UKERNEL) */
33 #include <afs/pthread_glock.h>
34 #include <sys/types.h>
40 #include <netinet/in.h>
46 #include "cellconfig.h"
49 #endif /* defined(UKERNEL) */
51 /* return a null security object if nothing else can be done */
52 static afs_int32 QuickAuth(astr, aindex)
53 struct rx_securityClass **astr;
55 register struct rx_securityClass *tc;
56 tc = rxnull_NewClientSecurityObject();
63 /* Return an appropriate security class and index */
64 afs_int32 afsconf_ServerAuth(adir, astr, aindex)
65 register struct afsconf_dir *adir;
66 struct rx_securityClass **astr;
68 register struct rx_securityClass *tclass;
71 tclass = (struct rx_securityClass *)
72 rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL);
75 *aindex = 2; /* kerberos security index */
84 #endif /* !defined(UKERNEL) */
86 static afs_int32 GenericAuth(adir, astr, aindex, enclevel)
87 struct afsconf_dir *adir;
88 struct rx_securityClass **astr;
90 rxkad_level enclevel; {
92 struct ktc_encryptionKey key, session;
93 struct rx_securityClass *tclass;
96 register afs_int32 code;
98 /* first, find the right key and kvno to use */
99 code = afsconf_GetLatestKey(adir, &kvno, &key);
101 return QuickAuth(astr, aindex);
104 /* next create random session key, using key for seed to good random */
105 des_init_random_number_generator (&key);
106 code = des_random_key (&session);
108 return QuickAuth(astr, aindex);
111 /* now create the actual ticket */
112 ticketLen = sizeof(tbuffer);
113 code = tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0,
114 0xffffffff, &session, 0, "afs", "");
115 /* parms were buffer, ticketlen, key to seal ticket with, principal
116 name, instance and cell, start time, end time, session key to seal
117 in ticket, inet host, server name and server instance */
119 return QuickAuth(astr, aindex);
122 /* Next, we have ticket, kvno and session key, authenticate the connection.
123 * We use a magic # instead of a constant because of basic compilation
124 * order when compiling the system from scratch (rx/rxkad.h isn't installed
126 tclass = (struct rx_securityClass *)
127 rxkad_NewClientSecurityObject(enclevel, &session, kvno,
130 *aindex = 2; /* kerberos security index */
134 /* build a fake ticket for 'afs' using keys from adir, returning an
135 * appropriate security class and index.
136 * astr is really a struct rx_securityClass.
138 afs_int32 afsconf_ClientAuth(struct afsconf_dir *adir, void *astr, afs_int32 *aindex)
143 rc = GenericAuth(adir, astr, aindex, rxkad_clear);
148 /* build a fake ticket for 'afs' using keys from adir, returning an
149 * appropriate security class and index. This one, unlike the above,
150 * tells rxkad to encrypt the data, too.
152 afs_int32 afsconf_ClientAuthSecure(adir, astr, aindex)
153 struct afsconf_dir *adir;
154 struct rx_securityClass **astr;
159 rc = GenericAuth(adir, astr, aindex, rxkad_crypt);