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>
19 #include "afs/sysincludes.h"
20 #include "afsincludes.h"
22 #include "afs/pthread_glock.h"
25 #include "afs/cellconfig.h"
28 #include "afs/pthread_glock.h"
29 #else /* defined(UKERNEL) */
31 #include <afs/pthread_glock.h>
32 #include <sys/types.h>
38 #include <netinet/in.h>
44 #include <des_prototypes.h>
47 #include "cellconfig.h"
50 #endif /* defined(UKERNEL) */
52 /* return a null security object if nothing else can be done */
54 QuickAuth(struct rx_securityClass **astr, afs_int32 *aindex)
56 register struct rx_securityClass *tc;
57 tc = rxnull_NewClientSecurityObject();
64 /* Return an appropriate security class and index */
66 afsconf_ServerAuth(void *arock,
67 struct rx_securityClass **astr,
70 struct afsconf_dir *adir = (struct afsconf_dir *) arock;
71 register struct rx_securityClass *tclass;
74 tclass = (struct rx_securityClass *)
75 rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL);
78 *aindex = 2; /* kerberos security index */
86 #endif /* !defined(UKERNEL) */
89 GenericAuth(struct afsconf_dir *adir,
90 struct rx_securityClass **astr,
95 struct ktc_encryptionKey key, session;
96 struct rx_securityClass *tclass;
99 register afs_int32 code;
101 /* first, find the right key and kvno to use */
102 code = afsconf_GetLatestKey(adir, &kvno, &key);
104 return QuickAuth(astr, aindex);
107 /* next create random session key, using key for seed to good random */
108 des_init_random_number_generator(ktc_to_cblock(&key));
109 code = des_random_key(ktc_to_cblock(&session));
111 return QuickAuth(astr, aindex);
114 /* now create the actual ticket */
115 ticketLen = sizeof(tbuffer);
116 memset(tbuffer, '\0', sizeof(tbuffer));
118 tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0,
119 0xffffffff, &session, 0, "afs", "");
120 /* parms were buffer, ticketlen, key to seal ticket with, principal
121 * name, instance and cell, start time, end time, session key to seal
122 * in ticket, inet host, server name and server instance */
124 return QuickAuth(astr, aindex);
127 /* Next, we have ticket, kvno and session key, authenticate the connection.
128 * We use a magic # instead of a constant because of basic compilation
129 * order when compiling the system from scratch (rx/rxkad.h isn't installed
131 tclass = (struct rx_securityClass *)
132 rxkad_NewClientSecurityObject(enclevel, &session, kvno, ticketLen,
135 *aindex = 2; /* kerberos security index */
139 /* build a fake ticket for 'afs' using keys from adir, returning an
140 * appropriate security class and index
143 afsconf_ClientAuth(void *arock, struct rx_securityClass ** astr,
146 struct afsconf_dir * adir = (struct afsconf_dir *) arock;
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.
160 afsconf_ClientAuthSecure(void *arock,
161 struct rx_securityClass **astr,
164 struct afsconf_dir *adir = (struct afsconf_dir *) arock;
168 rc = GenericAuth(adir, astr, aindex, rxkad_crypt);