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(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);
52 krb5_auth_con_setaddrs(context, auth_context, local_addr, remote_addr)
54 krb5_auth_context auth_context;
55 krb5_address * local_addr;
56 krb5_address * remote_addr;
58 /* Free old addresses */
59 if (auth_context->local_addr)
60 free(auth_context->local_addr);
61 if (auth_context->remote_addr)
62 free(auth_context->remote_addr);
65 if ((auth_context->local_addr = (krb5_address *)
66 malloc(sizeof(krb5_address) + local_addr->length)) == NULL) {
69 auth_context->local_addr->addrtype = local_addr->addrtype;
70 auth_context->local_addr->length = local_addr->length;
71 auth_context->local_addr->contents = (krb5_octet *)
72 auth_context->local_addr + sizeof(krb5_address);
73 memcpy(auth_context->local_addr->contents,
74 local_addr->contents, local_addr->length);
76 auth_context->local_addr = NULL;
80 if ((auth_context->remote_addr = (krb5_address *)
81 malloc(sizeof(krb5_address) + remote_addr->length)) == NULL) {
82 if (auth_context->local_addr)
83 free(auth_context->local_addr);
86 auth_context->remote_addr->addrtype = remote_addr->addrtype;
87 auth_context->remote_addr->length = remote_addr->length;
88 auth_context->remote_addr->contents = (krb5_octet *)
89 auth_context->remote_addr + sizeof(krb5_address);
90 memcpy(auth_context->remote_addr->contents,
91 remote_addr->contents, remote_addr->length);
93 auth_context->remote_addr = NULL;
99 krb5_auth_con_getaddrs(context, auth_context, local_addr, remote_addr)
100 krb5_context context;
101 krb5_auth_context auth_context;
102 krb5_address ** local_addr;
103 krb5_address ** remote_addr;
105 krb5_address * tmp_addr;
107 if (local_addr && auth_context->local_addr) {
108 if (!(tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))))
110 if ((tmp_addr->contents = malloc(auth_context->local_addr->length))) {
111 memcpy(tmp_addr->contents, auth_context->local_addr->contents,
112 auth_context->local_addr->length);
113 tmp_addr->addrtype = auth_context->local_addr->addrtype;
114 tmp_addr->length = auth_context->local_addr->length;
115 *local_addr = tmp_addr;
121 if ((remote_addr) && auth_context->remote_addr) {
122 if ((tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))) == NULL) {
123 if (local_addr && auth_context->local_addr) {
124 krb5_free_address(context, *local_addr);
128 if ((tmp_addr->contents = malloc(auth_context->remote_addr->length))) {
129 memcpy(tmp_addr->contents, auth_context->remote_addr->contents,
130 auth_context->remote_addr->length);
131 tmp_addr->addrtype = auth_context->remote_addr->addrtype;
132 tmp_addr->length = auth_context->remote_addr->length;
133 *remote_addr = tmp_addr;
135 if (local_addr && auth_context->local_addr) {
136 krb5_free_address(context, *local_addr);
146 krb5_auth_con_setports(context, auth_context, local_port, remote_port)
147 krb5_context context;
148 krb5_auth_context auth_context;
149 krb5_address * local_port;
150 krb5_address * remote_port;
152 /* Free old addresses */
153 if (auth_context->local_port)
154 free(auth_context->local_port);
155 if (auth_context->remote_port)
156 free(auth_context->remote_port);
159 if (((auth_context->local_port = (krb5_address *)
160 malloc(sizeof(krb5_address) + local_port->length)) == NULL)) {
163 auth_context->local_port->addrtype = local_port->addrtype;
164 auth_context->local_port->length = local_port->length;
165 auth_context->local_port->contents = (krb5_octet *)
166 auth_context->local_port + sizeof(krb5_address);
167 memcpy(auth_context->local_port->contents,
168 local_port->contents, local_port->length);
170 auth_context->local_port = NULL;
174 if ((auth_context->remote_port = (krb5_address *)
175 malloc(sizeof(krb5_address) + remote_port->length)) == NULL) {
176 if (auth_context->local_port)
177 free(auth_context->local_port);
180 auth_context->remote_port->addrtype = remote_port->addrtype;
181 auth_context->remote_port->length = remote_port->length;
182 auth_context->remote_port->contents = (krb5_octet *)
183 auth_context->remote_port + sizeof(krb5_address);
184 memcpy(auth_context->remote_port->contents,
185 remote_port->contents, remote_port->length);
187 auth_context->remote_port = NULL;
194 * This function overloads the keyblock field. It is only useful prior to
195 * a krb5_rd_req_decode() call for user to user authentication where the
196 * server has the key and needs to use it to decrypt the incoming request.
197 * Once decrypted this key is no longer necessary and is then overwritten
198 * with the session key sent by the client.
201 krb5_auth_con_setuseruserkey(context, auth_context, keyblock)
202 krb5_context context;
203 krb5_auth_context auth_context;
204 krb5_keyblock * keyblock;
206 if (auth_context->keyblock)
207 krb5_free_keyblock(context, auth_context->keyblock);
208 return(krb5_copy_keyblock(context, keyblock, &(auth_context->keyblock)));
212 krb5_auth_con_getkey(context, auth_context, keyblock)
213 krb5_context context;
214 krb5_auth_context auth_context;
215 krb5_keyblock ** keyblock;
217 if (auth_context->keyblock)
218 return krb5_copy_keyblock(context, auth_context->keyblock, keyblock);
224 krb5_auth_con_getlocalsubkey(context, auth_context, keyblock)
225 krb5_context context;
226 krb5_auth_context auth_context;
227 krb5_keyblock ** keyblock;
229 if (auth_context->local_subkey)
230 return krb5_copy_keyblock(context,auth_context->local_subkey,keyblock);
236 krb5_auth_con_getremotesubkey(context, auth_context, keyblock)
237 krb5_context context;
238 krb5_auth_context auth_context;
239 krb5_keyblock ** keyblock;
241 if (auth_context->remote_subkey)
242 return krb5_copy_keyblock(context,auth_context->remote_subkey,keyblock);
248 krb5_auth_con_setcksumtype(context, auth_context, cksumtype)
249 krb5_context context;
250 krb5_auth_context auth_context;
251 krb5_cksumtype cksumtype;
253 auth_context->cksumtype = cksumtype;
258 krb5_auth_con_getlocalseqnumber(context, auth_context, seqnumber)
259 krb5_context context;
260 krb5_auth_context auth_context;
261 krb5_int32 * seqnumber;
263 *seqnumber = auth_context->local_seq_number;
268 krb5_auth_con_getauthenticator(context, auth_context, authenticator)
269 krb5_context context;
270 krb5_auth_context auth_context;
271 krb5_authenticator ** authenticator;
273 return (krb5_copy_authenticator(context, auth_context->authentp,
278 krb5_auth_con_getremoteseqnumber(context, auth_context, seqnumber)
279 krb5_context context;
280 krb5_auth_context auth_context;
281 krb5_int32 * seqnumber;
283 *seqnumber = auth_context->remote_seq_number;
288 krb5_auth_con_initivector(context, auth_context)
289 krb5_context context;
290 krb5_auth_context auth_context;
292 if (auth_context->keyblock) {
293 int size = krb5_keytype_array[auth_context->keyblock->keytype]->
294 system->block_length;
296 if ((auth_context->i_vector = (krb5_pointer)malloc(size))) {
297 memset(auth_context->i_vector, 0, size);
302 return EINVAL; /* XXX need an error for no keyblock */
306 krb5_auth_con_setivector(context, auth_context, ivector)
307 krb5_context context;
308 krb5_auth_context auth_context;
309 krb5_pointer ivector;
311 auth_context->i_vector = ivector;
316 krb5_auth_con_getivector(context, auth_context, ivector)
317 krb5_context context;
318 krb5_auth_context auth_context;
319 krb5_pointer * ivector;
321 *ivector = auth_context->i_vector;
326 krb5_auth_con_setflags(context, auth_context, flags)
327 krb5_context context;
328 krb5_auth_context auth_context;
331 auth_context->auth_context_flags = flags;
336 krb5_auth_con_getflags(context, auth_context, flags)
337 krb5_context context;
338 krb5_auth_context auth_context;
341 *flags = auth_context->auth_context_flags;
346 krb5_auth_con_setrcache(context, auth_context, rcache)
347 krb5_context context;
348 krb5_auth_context auth_context;
351 auth_context->rcache = rcache;