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 memset(tbuffer, '\0', sizeof(tbuffer));
114 code = tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0,
115 0xffffffff, &session, 0, "afs", "");
116 /* parms were buffer, ticketlen, key to seal ticket with, principal
117 name, instance and cell, start time, end time, session key to seal
118 in ticket, inet host, server name and server instance */
120 return QuickAuth(astr, aindex);
123 /* Next, we have ticket, kvno and session key, authenticate the connection.
124 * We use a magic # instead of a constant because of basic compilation
125 * order when compiling the system from scratch (rx/rxkad.h isn't installed
127 tclass = (struct rx_securityClass *)
128 rxkad_NewClientSecurityObject(enclevel, &session, kvno,
131 *aindex = 2; /* kerberos security index */
135 /* build a fake ticket for 'afs' using keys from adir, returning an
136 * appropriate security class and index
138 afs_int32 afsconf_ClientAuth(struct afsconf_dir *adir,
139 struct rx_securityClass **astr, afs_int32 *aindex)
144 rc = GenericAuth(adir, astr, aindex, rxkad_clear);
149 /* build a fake ticket for 'afs' using keys from adir, returning an
150 * appropriate security class and index. This one, unlike the above,
151 * tells rxkad to encrypt the data, too.
153 afs_int32 afsconf_ClientAuthSecure(adir, astr, aindex)
154 struct afsconf_dir *adir;
155 struct rx_securityClass **astr;
160 rc = GenericAuth(adir, astr, aindex, rxkad_crypt);