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 "../afs/afsincludes.h"
22 #include "../afs/stds.h"
23 #include "../afs/pthread_glock.h"
24 #include "../des/des.h"
25 #include "../rx/rxkad.h"
27 #include "../afs/cellconfig.h"
28 #include "../afs/keys.h"
29 #include "../afs/auth.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) */
52 extern afs_int32 afsconf_Authenticate();
53 extern int afsconf_GetKey();
54 extern struct rx_securityClass *rxkad_NewServerSecurityObject();
55 extern struct rx_securityClass *rxkad_NewClientSecurityObject();
57 /* return a null security object if nothing else can be done */
58 static afs_int32 QuickAuth(astr, aindex)
59 struct rx_securityClass **astr;
61 register struct rx_securityClass *tc;
62 tc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
69 /* Return an appropriate security class and index */
70 afs_int32 afsconf_ServerAuth(adir, astr, aindex)
71 register struct afsconf_dir *adir;
72 struct rx_securityClass **astr;
74 register struct rx_securityClass *tclass;
77 tclass = (struct rx_securityClass *)
78 rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, (char *) 0);
81 *aindex = 2; /* kerberos security index */
90 #endif /* !defined(UKERNEL) */
92 static afs_int32 GenericAuth(adir, astr, aindex, enclevel)
93 struct afsconf_dir *adir;
94 struct rx_securityClass **astr;
96 rxkad_level enclevel; {
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 code = tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0,
120 0xffffffff, &session, 0, "afs", "");
121 /* parms were buffer, ticketlen, key to seal ticket with, principal
122 name, instance and cell, start time, end time, session key to seal
123 in ticket, inet host, server name and server instance */
125 return QuickAuth(astr, aindex);
128 /* Next, we have ticket, kvno and session key, authenticate the connection.
129 * We use a magic # instead of a constant because of basic compilation
130 * order when compiling the system from scratch (rx/rxkad.h isn't installed
132 tclass = (struct rx_securityClass *)
133 rxkad_NewClientSecurityObject(enclevel, &session, kvno,
136 *aindex = 2; /* kerberos security index */
140 /* build a fake ticket for 'afs' using keys from adir, returning an
141 * appropriate security class and index
143 afs_int32 afsconf_ClientAuth(adir, astr, aindex)
144 struct afsconf_dir *adir;
145 struct rx_securityClass **astr;
150 rc = GenericAuth(adir, astr, aindex, rxkad_clear);
155 /* build a fake ticket for 'afs' using keys from adir, returning an
156 * appropriate security class and index. This one, unlike the above,
157 * tells rxkad to encrypt the data, too.
159 afs_int32 afsconf_ClientAuthSecure(adir, astr, aindex)
160 struct afsconf_dir *adir;
161 struct rx_securityClass **astr;
166 rc = GenericAuth(adir, astr, aindex, rxkad_crypt);