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
11 #include "../afs/param.h"
12 #include "../afs/sysincludes.h"
13 #include "../afs/afsincludes.h"
14 #include "../afs/stds.h"
15 #include "../afs/pthread_glock.h"
16 #include "../des/des.h"
17 #include "../rx/rxkad.h"
19 #include "../afs/cellconfig.h"
20 #include "../afs/keys.h"
21 #include "../afs/auth.h"
22 #include "../afs/pthread_glock.h"
23 #else /* defined(UKERNEL) */
24 #include <afs/param.h>
26 #include <afs/pthread_glock.h>
27 #include <sys/types.h>
33 #include <netinet/in.h>
39 #include "cellconfig.h"
42 #endif /* defined(UKERNEL) */
45 extern afs_int32 afsconf_Authenticate();
46 extern int afsconf_GetKey();
47 extern struct rx_securityClass *rxkad_NewServerSecurityObject();
48 extern struct rx_securityClass *rxkad_NewClientSecurityObject();
50 /* return a null security object if nothing else can be done */
51 static afs_int32 QuickAuth(astr, aindex)
52 struct rx_securityClass **astr;
54 register struct rx_securityClass *tc;
55 tc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
62 /* Return an appropriate security class and index */
63 afs_int32 afsconf_ServerAuth(adir, astr, aindex)
64 register struct afsconf_dir *adir;
65 struct rx_securityClass **astr;
67 register struct rx_securityClass *tclass;
70 tclass = (struct rx_securityClass *)
71 rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, (char *) 0);
74 *aindex = 2; /* kerberos security index */
83 #endif /* !defined(UKERNEL) */
85 static afs_int32 GenericAuth(adir, astr, aindex, enclevel)
86 struct afsconf_dir *adir;
87 struct rx_securityClass **astr;
89 rxkad_level enclevel; {
91 struct ktc_encryptionKey key, session;
92 struct rx_securityClass *tclass;
96 Key_schedule schedule;
97 register afs_int32 i, code;
99 /* first, find the right key and kvno to use */
100 code = afsconf_GetLatestKey(adir, &kvno, &key);
102 return QuickAuth(astr, aindex);
105 /* next create random session key, using key for seed to good random */
106 des_init_random_number_generator (&key);
107 code = des_random_key (&session);
109 return QuickAuth(astr, aindex);
112 /* now create the actual ticket */
113 ticketLen = 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(adir, astr, aindex)
139 struct afsconf_dir *adir;
140 struct rx_securityClass **astr;
145 rc = GenericAuth(adir, astr, aindex, rxkad_clear);
150 /* build a fake ticket for 'afs' using keys from adir, returning an
151 * appropriate security class and index. This one, unlike the above,
152 * tells rxkad to encrypt the data, too.
154 afs_int32 afsconf_ClientAuthSecure(adir, astr, aindex)
155 struct afsconf_dir *adir;
156 struct rx_securityClass **astr;
161 rc = GenericAuth(adir, astr, aindex, rxkad_crypt);