6 krb5_auth_con_init(context, auth_context)
8 krb5_auth_context ** auth_context;
10 if (*auth_context = (krb5_auth_context *)malloc(sizeof(krb5_auth_context))){
11 memset(*auth_context, 0, sizeof(krb5_auth_context));
13 /* Default flags, do time not seq */
14 (*auth_context)->auth_context_flags =
15 KRB5_AUTH_CONTEXT_DO_TIME | KRB5_AUTH_CONN_INITIALIZED;
17 (*auth_context)->cksumtype = CKSUMTYPE_RSA_MD4_DES;
18 /* (*auth_context)->cksumtype = CKSUMTYPE_CRC32; */
25 krb5_auth_con_free(context, auth_context)
27 krb5_auth_context * auth_context;
29 if (auth_context->local_addr)
30 free(auth_context->local_addr);
31 if (auth_context->remote_addr)
32 free(auth_context->remote_addr);
33 if (auth_context->local_port)
34 free(auth_context->local_port);
35 if (auth_context->remote_port)
36 free(auth_context->remote_port);
37 if (auth_context->authentp)
38 krb5_free_authenticator(context, auth_context->authentp);
39 if (auth_context->keyblock)
40 krb5_free_keyblock(context, auth_context->keyblock);
41 if (auth_context->local_subkey)
42 krb5_free_keyblock(context, auth_context->local_subkey);
43 if (auth_context->remote_subkey)
44 krb5_free_keyblock(context, auth_context->remote_subkey);
50 krb5_auth_con_setaddrs(context, auth_context, local_addr, remote_addr)
52 krb5_auth_context * auth_context;
53 krb5_address * local_addr;
54 krb5_address * remote_addr;
56 /* Free old addresses */
57 if (auth_context->local_addr)
58 free(auth_context->local_addr);
59 if (auth_context->remote_addr)
60 free(auth_context->remote_addr);
63 if ((auth_context->local_addr = (krb5_address *)
64 malloc(sizeof(krb5_address) + local_addr->length)) == NULL) {
67 auth_context->local_addr->addrtype = local_addr->addrtype;
68 auth_context->local_addr->length = local_addr->length;
69 auth_context->local_addr->contents = (krb5_octet *)
70 auth_context->local_addr + sizeof(krb5_address);
71 memcpy(auth_context->local_addr->contents,
72 local_addr->contents, local_addr->length);
74 auth_context->local_addr = NULL;
78 if ((auth_context->remote_addr = (krb5_address *)
79 malloc(sizeof(krb5_address) + remote_addr->length)) == NULL) {
80 if (auth_context->local_addr)
81 free(auth_context->local_addr);
84 auth_context->remote_addr->addrtype = remote_addr->addrtype;
85 auth_context->remote_addr->length = remote_addr->length;
86 auth_context->remote_addr->contents = (krb5_octet *)
87 auth_context->remote_addr + sizeof(krb5_address);
88 memcpy(auth_context->remote_addr->contents,
89 remote_addr->contents, remote_addr->length);
91 auth_context->remote_addr = NULL;
97 krb5_auth_con_getaddrs(context, auth_context, local_addr, remote_addr)
99 krb5_auth_context * auth_context;
100 krb5_address ** local_addr;
101 krb5_address ** remote_addr;
103 krb5_address * tmp_addr;
105 if (local_addr && auth_context->local_addr) {
106 if ((tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))) == NULL)
108 if (tmp_addr->contents = malloc(auth_context->local_addr->length)) {
109 memcpy(tmp_addr->contents, auth_context->local_addr->contents,
110 auth_context->local_addr->length);
111 tmp_addr->addrtype = auth_context->local_addr->addrtype;
112 tmp_addr->length = auth_context->local_addr->length;
113 *local_addr = tmp_addr;
119 if ((remote_addr) && auth_context->remote_addr) {
120 if ((tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))) == NULL) {
121 if (local_addr && auth_context->local_addr) {
122 krb5_free_address(context, *local_addr);
126 if (tmp_addr->contents = malloc(auth_context->remote_addr->length)) {
127 memcpy(tmp_addr->contents, auth_context->remote_addr->contents,
128 auth_context->remote_addr->length);
129 tmp_addr->addrtype = auth_context->remote_addr->addrtype;
130 tmp_addr->length = auth_context->remote_addr->length;
131 *remote_addr = tmp_addr;
133 if (local_addr && auth_context->local_addr) {
134 krb5_free_address(context, *local_addr);
144 krb5_auth_con_setports(context, auth_context, local_port, remote_port)
145 krb5_context context;
146 krb5_auth_context * auth_context;
147 krb5_address * local_port;
148 krb5_address * remote_port;
150 /* Free old addresses */
151 if (auth_context->local_port)
152 free(auth_context->local_port);
153 if (auth_context->remote_port)
154 free(auth_context->remote_port);
157 if ((auth_context->local_port = (krb5_address *)
158 malloc(sizeof(krb5_address) + local_port->length)) == NULL) {
161 auth_context->local_port->addrtype = local_port->addrtype;
162 auth_context->local_port->length = local_port->length;
163 auth_context->local_port->contents = (krb5_octet *)
164 auth_context->local_port + sizeof(krb5_address);
165 memcpy(auth_context->local_port->contents,
166 local_port->contents, local_port->length);
168 auth_context->local_port = NULL;
172 if ((auth_context->remote_port = (krb5_address *)
173 malloc(sizeof(krb5_address) + remote_port->length)) == NULL) {
174 if (auth_context->local_port)
175 free(auth_context->local_port);
178 auth_context->remote_port->addrtype = remote_port->addrtype;
179 auth_context->remote_port->length = remote_port->length;
180 auth_context->remote_port->contents = (krb5_octet *)
181 auth_context->remote_port + sizeof(krb5_address);
182 memcpy(auth_context->remote_port->contents,
183 remote_port->contents, remote_port->length);
185 auth_context->remote_port = NULL;
192 * This function overloads the keyblock field. It is only useful prior to
193 * a krb5_rd_req_decode() call for user to user authentication where the
194 * server has the key and needs to use it to decrypt the incoming request.
195 * Once decrypted this key is no longer necessary and is then overwritten
196 * with the session key sent by the client.
199 krb5_auth_con_setuseruserkey(context, auth_context, keyblock)
200 krb5_context context;
201 krb5_auth_context * auth_context;
202 krb5_keyblock * keyblock;
204 if (auth_context->keyblock)
205 krb5_free_keyblock(context, auth_context->keyblock);
206 return(krb5_copy_keyblock(context, keyblock, &(auth_context->keyblock)));
210 krb5_auth_con_getkey(context, auth_context, keyblock)
211 krb5_context context;
212 krb5_auth_context * auth_context;
213 krb5_keyblock ** keyblock;
215 if (auth_context->keyblock)
216 return krb5_copy_keyblock(context, auth_context->keyblock, keyblock);
222 krb5_auth_con_getlocalsubkey(context, auth_context, keyblock)
223 krb5_context context;
224 krb5_auth_context * auth_context;
225 krb5_keyblock ** keyblock;
227 if (auth_context->local_subkey)
228 return krb5_copy_keyblock(context,auth_context->local_subkey,keyblock);
234 krb5_auth_con_getremotesubkey(context, auth_context, keyblock)
235 krb5_context context;
236 krb5_auth_context * auth_context;
237 krb5_keyblock ** keyblock;
239 if (auth_context->remote_subkey)
240 return krb5_copy_keyblock(context,auth_context->remote_subkey,keyblock);
246 krb5_auth_con_setcksumtype(context, auth_context, cksumtype)
247 krb5_context context;
248 krb5_auth_context * auth_context;
249 krb5_cksumtype cksumtype;
251 auth_context->cksumtype = cksumtype;
256 krb5_auth_con_getlocalseqnumber(context, auth_context, seqnumber)
257 krb5_context context;
258 krb5_auth_context * auth_context;
259 krb5_int32 * seqnumber;
261 *seqnumber = auth_context->local_seq_number;
266 krb5_auth_con_getauthenticator(context, auth_context, authenticator)
267 krb5_context context;
268 krb5_auth_context * auth_context;
269 krb5_authenticator ** authenticator;
271 return (krb5_copy_authenticator(context, auth_context->authentp,
276 krb5_auth_con_getremoteseqnumber(context, auth_context, seqnumber)
277 krb5_context context;
278 krb5_auth_context * auth_context;
279 krb5_int32 * seqnumber;
281 *seqnumber = auth_context->remote_seq_number;
286 krb5_auth_con_initivector(context, auth_context)
287 krb5_context context;
288 krb5_auth_context * auth_context;
290 if (auth_context->keyblock) {
291 int size = krb5_keytype_array[auth_context->keyblock->keytype]->
292 system->block_length;
294 if (auth_context->i_vector = (krb5_pointer)malloc(size)) {
295 memset(auth_context->i_vector, 0, size);
300 return EINVAL; /* XXX need an error for no keyblock */
304 krb5_auth_con_setivector(context, auth_context, ivector)
305 krb5_context context;
306 krb5_auth_context * auth_context;
307 krb5_pointer ivector;
309 auth_context->i_vector = ivector;
314 krb5_auth_con_getivector(context, auth_context, ivector)
315 krb5_context context;
316 krb5_auth_context * auth_context;
317 krb5_pointer * ivector;
319 *ivector = auth_context->i_vector;
324 krb5_auth_con_setflags(context, auth_context, flags)
325 krb5_context context;
326 krb5_auth_context * auth_context;
329 auth_context->auth_context_flags = flags;
334 krb5_auth_con_getflags(context, auth_context, flags)
335 krb5_context context;
336 krb5_auth_context * auth_context;
339 *flags = auth_context->auth_context_flags;
344 krb5_auth_con_setrcache(context, auth_context, rcache)
345 krb5_context context;
346 krb5_auth_context * auth_context;
349 auth_context->rcache = rcache;