6 krb5_auth_con_init(context, auth_context)
8 krb5_auth_context * auth_context;
11 (krb5_auth_context)malloc(sizeof(struct _krb5_auth_context));
15 memset(*auth_context, 0, sizeof(struct _krb5_auth_context));
17 /* Default flags, do time not seq */
18 (*auth_context)->auth_context_flags =
19 KRB5_AUTH_CONTEXT_DO_TIME | KRB5_AUTH_CONN_INITIALIZED;
21 (*auth_context)->cksumtype = CKSUMTYPE_RSA_MD4_DES;
22 /* (*auth_context)->cksumtype = CKSUMTYPE_CRC32; */
27 krb5_auth_con_free(context, auth_context)
29 krb5_auth_context auth_context;
31 if (auth_context->local_addr)
32 free(auth_context->local_addr);
33 if (auth_context->remote_addr)
34 free(auth_context->remote_addr);
35 if (auth_context->local_port)
36 free(auth_context->local_port);
37 if (auth_context->remote_port)
38 free(auth_context->remote_port);
39 if (auth_context->authentp)
40 krb5_free_authenticator(context, auth_context->authentp);
41 if (auth_context->keyblock)
42 krb5_free_keyblock(context, auth_context->keyblock);
43 if (auth_context->local_subkey)
44 krb5_free_keyblock(context, auth_context->local_subkey);
45 if (auth_context->remote_subkey)
46 krb5_free_keyblock(context, auth_context->remote_subkey);
47 if (auth_context->rcache)
48 krb5_rc_close(context, auth_context->rcache);
54 krb5_auth_con_setaddrs(context, auth_context, local_addr, remote_addr)
56 krb5_auth_context auth_context;
57 krb5_address * local_addr;
58 krb5_address * remote_addr;
60 /* Free old addresses */
61 if (auth_context->local_addr)
62 free(auth_context->local_addr);
63 if (auth_context->remote_addr)
64 free(auth_context->remote_addr);
67 if ((auth_context->local_addr = (krb5_address *)
68 malloc(sizeof(krb5_address) + local_addr->length)) == NULL) {
71 auth_context->local_addr->addrtype = local_addr->addrtype;
72 auth_context->local_addr->length = local_addr->length;
73 auth_context->local_addr->contents = (krb5_octet *)
74 auth_context->local_addr + sizeof(krb5_address);
75 memcpy(auth_context->local_addr->contents,
76 local_addr->contents, local_addr->length);
78 auth_context->local_addr = NULL;
82 if ((auth_context->remote_addr = (krb5_address *)
83 malloc(sizeof(krb5_address) + remote_addr->length)) == NULL) {
84 if (auth_context->local_addr)
85 free(auth_context->local_addr);
88 auth_context->remote_addr->addrtype = remote_addr->addrtype;
89 auth_context->remote_addr->length = remote_addr->length;
90 auth_context->remote_addr->contents = (krb5_octet *)
91 auth_context->remote_addr + sizeof(krb5_address);
92 memcpy(auth_context->remote_addr->contents,
93 remote_addr->contents, remote_addr->length);
95 auth_context->remote_addr = NULL;
101 krb5_auth_con_getaddrs(context, auth_context, local_addr, remote_addr)
102 krb5_context context;
103 krb5_auth_context auth_context;
104 krb5_address ** local_addr;
105 krb5_address ** remote_addr;
107 krb5_address * tmp_addr;
109 if (local_addr && auth_context->local_addr) {
110 if (!(tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))))
112 if ((tmp_addr->contents = malloc(auth_context->local_addr->length))) {
113 memcpy(tmp_addr->contents, auth_context->local_addr->contents,
114 auth_context->local_addr->length);
115 tmp_addr->addrtype = auth_context->local_addr->addrtype;
116 tmp_addr->length = auth_context->local_addr->length;
117 *local_addr = tmp_addr;
123 if ((remote_addr) && auth_context->remote_addr) {
124 if ((tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))) == NULL) {
125 if (local_addr && auth_context->local_addr) {
126 krb5_free_address(context, *local_addr);
130 if ((tmp_addr->contents = malloc(auth_context->remote_addr->length))) {
131 memcpy(tmp_addr->contents, auth_context->remote_addr->contents,
132 auth_context->remote_addr->length);
133 tmp_addr->addrtype = auth_context->remote_addr->addrtype;
134 tmp_addr->length = auth_context->remote_addr->length;
135 *remote_addr = tmp_addr;
137 if (local_addr && auth_context->local_addr) {
138 krb5_free_address(context, *local_addr);
148 krb5_auth_con_setports(context, auth_context, local_port, remote_port)
149 krb5_context context;
150 krb5_auth_context auth_context;
151 krb5_address * local_port;
152 krb5_address * remote_port;
154 /* Free old addresses */
155 if (auth_context->local_port)
156 free(auth_context->local_port);
157 if (auth_context->remote_port)
158 free(auth_context->remote_port);
161 if (((auth_context->local_port = (krb5_address *)
162 malloc(sizeof(krb5_address) + local_port->length)) == NULL)) {
165 auth_context->local_port->addrtype = local_port->addrtype;
166 auth_context->local_port->length = local_port->length;
167 auth_context->local_port->contents = (krb5_octet *)
168 auth_context->local_port + sizeof(krb5_address);
169 memcpy(auth_context->local_port->contents,
170 local_port->contents, local_port->length);
172 auth_context->local_port = NULL;
176 if ((auth_context->remote_port = (krb5_address *)
177 malloc(sizeof(krb5_address) + remote_port->length)) == NULL) {
178 if (auth_context->local_port)
179 free(auth_context->local_port);
182 auth_context->remote_port->addrtype = remote_port->addrtype;
183 auth_context->remote_port->length = remote_port->length;
184 auth_context->remote_port->contents = (krb5_octet *)
185 auth_context->remote_port + sizeof(krb5_address);
186 memcpy(auth_context->remote_port->contents,
187 remote_port->contents, remote_port->length);
189 auth_context->remote_port = NULL;
196 * This function overloads the keyblock field. It is only useful prior to
197 * a krb5_rd_req_decode() call for user to user authentication where the
198 * server has the key and needs to use it to decrypt the incoming request.
199 * Once decrypted this key is no longer necessary and is then overwritten
200 * with the session key sent by the client.
203 krb5_auth_con_setuseruserkey(context, auth_context, keyblock)
204 krb5_context context;
205 krb5_auth_context auth_context;
206 krb5_keyblock * keyblock;
208 if (auth_context->keyblock)
209 krb5_free_keyblock(context, auth_context->keyblock);
210 return(krb5_copy_keyblock(context, keyblock, &(auth_context->keyblock)));
214 krb5_auth_con_getkey(context, auth_context, keyblock)
215 krb5_context context;
216 krb5_auth_context auth_context;
217 krb5_keyblock ** keyblock;
219 if (auth_context->keyblock)
220 return krb5_copy_keyblock(context, auth_context->keyblock, keyblock);
226 krb5_auth_con_getlocalsubkey(context, auth_context, keyblock)
227 krb5_context context;
228 krb5_auth_context auth_context;
229 krb5_keyblock ** keyblock;
231 if (auth_context->local_subkey)
232 return krb5_copy_keyblock(context,auth_context->local_subkey,keyblock);
238 krb5_auth_con_getremotesubkey(context, auth_context, keyblock)
239 krb5_context context;
240 krb5_auth_context auth_context;
241 krb5_keyblock ** keyblock;
243 if (auth_context->remote_subkey)
244 return krb5_copy_keyblock(context,auth_context->remote_subkey,keyblock);
250 krb5_auth_con_setcksumtype(context, auth_context, cksumtype)
251 krb5_context context;
252 krb5_auth_context auth_context;
253 krb5_cksumtype cksumtype;
255 auth_context->cksumtype = cksumtype;
260 krb5_auth_con_getlocalseqnumber(context, auth_context, seqnumber)
261 krb5_context context;
262 krb5_auth_context auth_context;
263 krb5_int32 * seqnumber;
265 *seqnumber = auth_context->local_seq_number;
270 krb5_auth_con_getauthenticator(context, auth_context, authenticator)
271 krb5_context context;
272 krb5_auth_context auth_context;
273 krb5_authenticator ** authenticator;
275 return (krb5_copy_authenticator(context, auth_context->authentp,
280 krb5_auth_con_getremoteseqnumber(context, auth_context, seqnumber)
281 krb5_context context;
282 krb5_auth_context auth_context;
283 krb5_int32 * seqnumber;
285 *seqnumber = auth_context->remote_seq_number;
290 krb5_auth_con_initivector(context, auth_context)
291 krb5_context context;
292 krb5_auth_context auth_context;
294 if (auth_context->keyblock) {
295 int size = krb5_keytype_array[auth_context->keyblock->keytype]->
296 system->block_length;
298 if ((auth_context->i_vector = (krb5_pointer)malloc(size))) {
299 memset(auth_context->i_vector, 0, size);
304 return EINVAL; /* XXX need an error for no keyblock */
308 krb5_auth_con_setivector(context, auth_context, ivector)
309 krb5_context context;
310 krb5_auth_context auth_context;
311 krb5_pointer ivector;
313 auth_context->i_vector = ivector;
318 krb5_auth_con_getivector(context, auth_context, ivector)
319 krb5_context context;
320 krb5_auth_context auth_context;
321 krb5_pointer * ivector;
323 *ivector = auth_context->i_vector;
328 krb5_auth_con_setflags(context, auth_context, flags)
329 krb5_context context;
330 krb5_auth_context auth_context;
333 auth_context->auth_context_flags = flags;
338 krb5_auth_con_getflags(context, auth_context, flags)
339 krb5_context context;
340 krb5_auth_context auth_context;
343 *flags = auth_context->auth_context_flags;
348 krb5_auth_con_setrcache(context, auth_context, rcache)
349 krb5_context context;
350 krb5_auth_context auth_context;
353 auth_context->rcache = rcache;
358 krb5_auth_con_getrcache(context, auth_context, rcache)
359 krb5_context context;
360 krb5_auth_context auth_context;
361 krb5_rcache * rcache;
363 *rcache = auth_context->rcache;