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>
48 #include "cellconfig.h"
51 #endif /* defined(UKERNEL) */
53 /* return a null security object if nothing else can be done */
55 QuickAuth(astr, aindex)
56 struct rx_securityClass **astr;
59 register struct rx_securityClass *tc;
60 tc = rxnull_NewClientSecurityObject();
67 /* Return an appropriate security class and index */
69 afsconf_ServerAuth(adir, astr, aindex)
70 register struct afsconf_dir *adir;
71 struct rx_securityClass **astr;
74 register struct rx_securityClass *tclass;
77 tclass = (struct rx_securityClass *)
78 rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL);
81 *aindex = 2; /* kerberos security index */
89 #endif /* !defined(UKERNEL) */
92 GenericAuth(adir, astr, aindex, enclevel)
93 struct afsconf_dir *adir;
94 struct rx_securityClass **astr;
99 struct ktc_encryptionKey key, session;
100 struct rx_securityClass *tclass;
103 register afs_int32 code;
105 /* first, find the right key and kvno to use */
106 code = afsconf_GetLatestKey(adir, &kvno, &key);
108 return QuickAuth(astr, aindex);
111 /* next create random session key, using key for seed to good random */
112 des_init_random_number_generator(&key);
113 code = des_random_key(&session);
115 return QuickAuth(astr, aindex);
118 /* now create the actual ticket */
119 ticketLen = sizeof(tbuffer);
120 memset(tbuffer, '\0', sizeof(tbuffer));
122 tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0,
123 0xffffffff, &session, 0, "afs", "");
124 /* parms were buffer, ticketlen, key to seal ticket with, principal
125 * name, instance and cell, start time, end time, session key to seal
126 * in ticket, inet host, server name and server instance */
128 return QuickAuth(astr, aindex);
131 /* Next, we have ticket, kvno and session key, authenticate the connection.
132 * We use a magic # instead of a constant because of basic compilation
133 * order when compiling the system from scratch (rx/rxkad.h isn't installed
135 tclass = (struct rx_securityClass *)
136 rxkad_NewClientSecurityObject(enclevel, &session, kvno, ticketLen,
139 *aindex = 2; /* kerberos security index */
143 /* build a fake ticket for 'afs' using keys from adir, returning an
144 * appropriate security class and index
147 afsconf_ClientAuth(struct afsconf_dir * adir, struct rx_securityClass ** astr,
153 rc = GenericAuth(adir, astr, aindex, rxkad_clear);
158 /* build a fake ticket for 'afs' using keys from adir, returning an
159 * appropriate security class and index. This one, unlike the above,
160 * tells rxkad to encrypt the data, too.
163 afsconf_ClientAuthSecure(adir, astr, aindex)
164 struct afsconf_dir *adir;
165 struct rx_securityClass **astr;
171 rc = GenericAuth(adir, astr, aindex, rxkad_crypt);