Standardize License information
[openafs.git] / src / rxkad / private_data.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 /* Declarations of data structures associated with rxkad security objects. */
11
12 #ifndef TRANSARC_RXKAD_PRIVATE_DATA_H
13 #define TRANSARC_RXKAD_PRIVATE_DATA_H
14
15 #include "rxkad.h"
16
17
18 #include "fcrypt.h"
19
20 struct connStats {
21     afs_uint32
22         bytesReceived, bytesSent, packetsReceived, packetsSent;
23 };
24         
25 /* Private data structure representing an RX server end point for rxkad.
26  * This structure is encrypted in network byte order and transmitted as
27  * part of a challenge response.  It is also used as part of the per-packet
28  * checksum sent on every packet, to ensure that the per-packet checksum
29  * is not used in the context of another end point.
30  *
31  * THIS STRUCTURE MUST BE A MULTIPLE OF 8 BYTES LONG SINCE IT IS
32  * ENCRYPTED IN PLACE!
33  */
34 struct rxkad_endpoint {
35     afs_int32 cuid[2];                  /* being used for connection routing */
36     afs_uint32 cksum;                   /* cksum of challenge response */
37     afs_int32 securityIndex;                    /* security index */
38 };
39
40 /* structure used for generating connection IDs; must be encrypted in network
41  * byte order.  Also must be a multiple of 8 bytes for encryption to work
42  * properly.
43  */
44 struct rxkad_cidgen {
45     struct clock time;  /* time now */
46     afs_int32 random1;  /* some implementation-specific random info */
47     afs_int32 random2;  /* more random info */
48     afs_int32 counter;  /* a counter */
49     afs_int32 ipAddr;   /* or an approximation to it */
50 };
51
52 /* private data in client-side security object */
53 struct rxkad_cprivate {
54     afs_int32      kvno;                /* key version of ticket */
55     afs_int32      ticketLen;           /* length of ticket */
56     fc_KeySchedule keysched;            /* the session key */
57     fc_InitializationVector ivec;       /* initialization vector for cbc */
58     char           ticket[MAXKTCTICKETLEN]; /* the ticket for the server */
59     rxkad_type     type;                /* always client */
60     rxkad_level    level;               /* minimum security level of client */
61 };
62
63 /* Per connection client-side info */
64 struct rxkad_cconn {
65     fc_InitializationVector preSeq;     /* used in computing checksum */
66     struct connStats stats;
67     char             cksumSeen;         /* rx: header.spare is a checksum */
68 };
69
70 /* private data in server-side security object */
71 struct rxkad_sprivate {
72     char       *get_key_rock;           /* rock for get_key function */
73     int       (*get_key)();             /* func. of kvno and server key ptr */
74     int       (*user_ok)();             /* func called with new client name */
75     rxkad_type  type;                   /* always server */
76     rxkad_level level;                  /* minimum security level of server */
77 };
78
79 /* private data in server-side connection */
80 struct rxkad_sconn {
81     rxkad_level      level;             /* security level of connection */
82     char             tried;             /* did we ever try to auth this conn */
83     char             authenticated;     /* connection is good */
84     char             cksumSeen;         /* rx: header.spare is a checksum */
85     afs_uint32    expirationTime;       /* when the ticket expires */
86     afs_int32        challengeID;       /* unique challenge */
87     struct connStats stats;             /* per connection stats */
88     fc_KeySchedule   keysched;          /* session key */
89     fc_InitializationVector ivec;       /* initialization vector for cbc */
90     fc_InitializationVector preSeq;     /* used in computing checksum */
91     struct rxkad_serverinfo *rock;      /* info about client if saved */
92 };
93
94 struct rxkad_serverinfo {
95     int kvno;
96     struct ktc_principal client;
97 };
98
99 #define RXKAD_CHALLENGE_PROTOCOL_VERSION 2
100
101 /* An old style (any version predating 2) challenge packet */
102 struct rxkad_oldChallenge {
103     afs_int32 challengeID;
104     afs_int32 level;                            /* minimum security level */
105 };
106
107 /* A version 2 challenge */
108 struct rxkad_v2Challenge {
109     afs_int32 version;
110     afs_int32 challengeID;
111     afs_int32 level;
112     afs_int32 spare;
113 };
114
115 /* An old challenge response packet */
116 struct rxkad_oldChallengeResponse {
117     struct { /* encrypted with session key */
118         afs_int32 incChallengeID;
119         afs_int32 level;
120     } encrypted;
121     afs_int32 kvno;
122     afs_int32 ticketLen;
123 };
124 /*  <ticketLen> bytes of ticket follow here */
125
126 /* A version 2 challenge response also includes connection routing (Rx server
127  * end point) and client call number state as well as version and spare fields.
128  * The encrypted part probably doesn't need to start on an 8 byte boundary, but
129  * just in case we put in a spare. */
130 struct rxkad_v2ChallengeResponse {
131     afs_int32 version;
132     afs_int32 spare;
133     struct { /* encrypted with session key */
134         struct rxkad_endpoint endpoint; /* for connection routing */
135         afs_int32 callNumbers[RX_MAXCALLS];     /* client call # state */
136         afs_int32 incChallengeID;
137         afs_int32 level;
138     } encrypted;
139     afs_int32 kvno;
140     afs_int32 ticketLen;
141 };
142 /*  <ticketLen> bytes of ticket follow here */
143 #if RX_MAXCALLS != 4
144     The above structure requires that (RX_MAXCALLS == 4).
145 #endif
146
147 /* This should be afs_int32, but the RXS ops are defined as int returning  */
148 #define rxs_return_t int
149 extern rxs_return_t
150     rxkad_Close(),
151     rxkad_NewConnection(),
152     rxkad_CheckAuthentication(),
153     rxkad_CreateChallenge(),
154     rxkad_GetChallenge(),
155     rxkad_GetResponse(),
156     rxkad_CheckPacket(),
157     rxkad_PreparePacket(),
158     rxkad_CheckResponse(),
159     rxkad_DestroyConnection(),
160     rxkad_AllocCID(),
161     rxkad_GetStats();
162
163 #endif /* TRANSARC_RXKAD_PRIVATE_DATA_H */