Add rxgk boilerplate
[openafs.git] / src / rxgk / rxgk_private.h
1 /* src/rxgk/rxgk_private.h - Declarations of RXGK-internal routines */
2 /*
3  * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  *   notice, this list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright
14  *   notice, this list of conditions and the following disclaimer in
15  *   the documentation and/or other materials provided with the
16  *   distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 /*
33  * Prototypes for routines internal to RXGK.
34  */
35
36 #ifndef RXGK_PRIVATE_H
37 #define RXGK_PRIVATE_H
38
39 /* RX-internal headers we depend on. */
40 #include <rx/rx_identity.h>
41
42 /** Statistics about a connection.  Bytes and packets sent/received. */
43 struct rxgkStats {
44     afs_uint32 brecv;
45     afs_uint32 bsent;
46     afs_uint32 precv;
47     afs_uint32 psent;
48 };
49
50 /*
51  * rgxk_server.c
52  */
53
54 /**
55  * Security Object private data for the server.
56  *
57  * Per-connection flags, and a way to get a decryption key for what the client
58  * sends us.
59  */
60 struct rxgk_sprivate {
61     afs_int32 flags;
62     void *rock;
63     rxgk_getkey_func getkey;
64 };
65 /**
66  * Per-connection security data for the server.
67  *
68  * Security level, authentication state, expiration, the current challenge
69  * nonce, status, the connection start time and current key derivation key
70  * number.  Cache both the user identity and callback identity presented
71  * in the token, for later use.
72  */
73 struct rxgk_sconn {
74     RXGK_Level level;
75     unsigned char tried_auth;
76     unsigned char auth;
77     rxgkTime expiration;
78     unsigned char challenge[20];
79     struct rxgkStats stats;
80     rxgkTime start_time;
81     struct rx_identity *client;
82     afs_uint32 key_number;
83     rxgk_key k0;
84     RXGK_Data cb_tok;
85     rxgk_key cb_key;
86 };
87
88 /*
89  * rxgk_client.c
90  */
91
92 /**
93  * Security Object private data for client.
94  *
95  * The session key ("token master key"), plust the enctype of the
96  * token and the token itself.
97  * UUIDs for both the client (cache manager) and target server.  This is
98  * doable because the token is either a db server (the target has no UUID)
99  * or tied to a particular file server (which does have a UUID).
100  */
101 struct rxgk_cprivate {
102     afs_int32 flags;
103     rxgk_key k0;
104     afs_int32 enctype;
105     RXGK_Level level;
106     RXGK_Data token;
107     afsUUID *client_uuid;
108     afsUUID *target_uuid;
109 };
110 /**
111  * Per-connection security data for client.
112  *
113  * The start time of the connection and connection key number are used
114  * for key derivation, information about the callback key to be presented in
115  * the authenticator for the connection, and the requisite connection
116  * statistics.
117  */
118 struct rxgk_cconn {
119     rxgkTime start_time;
120     afs_uint32 key_number;
121     RXGK_Data cb_tok;
122     RXGK_Data cb_k0;
123     afs_int32 cb_enctype;
124     struct rxgkStats stats;
125 };
126
127 #endif /* RXGK_PRIVATE_H */