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->authentp)
30 krb5_free_authenticator(context, auth_context->authentp);
31 if (auth_context->keyblock)
32 krb5_free_keyblock(context, auth_context->keyblock);
33 if (auth_context->local_subkey)
34 krb5_free_keyblock(context, auth_context->local_subkey);
35 if (auth_context->remote_subkey)
36 krb5_free_keyblock(context, auth_context->remote_subkey);
42 krb5_auth_con_setaddrs(context, auth_context, local_addr, remote_addr)
44 krb5_auth_context * auth_context;
45 krb5_address * local_addr;
46 krb5_address * remote_addr;
48 /* Free old addresses */
49 if (auth_context->local_addr)
50 free(auth_context->local_addr);
51 if (auth_context->remote_addr)
52 free(auth_context->remote_addr);
55 if ((auth_context->local_addr = (krb5_address *)
56 malloc(sizeof(krb5_address) + local_addr->length)) == NULL) {
59 auth_context->local_addr->addrtype = local_addr->addrtype;
60 auth_context->local_addr->length = local_addr->length;
61 auth_context->local_addr->contents = (krb5_octet *)
62 auth_context->local_addr + sizeof(krb5_address);
63 memcpy(auth_context->local_addr->contents,
64 local_addr->contents, local_addr->length);
66 auth_context->local_addr = NULL;
70 if ((auth_context->remote_addr = (krb5_address *)
71 malloc(sizeof(krb5_address) + remote_addr->length)) == NULL) {
72 if (auth_context->local_addr)
73 free(auth_context->local_addr);
76 auth_context->remote_addr->addrtype = remote_addr->addrtype;
77 auth_context->remote_addr->length = remote_addr->length;
78 auth_context->remote_addr->contents = (krb5_octet *)
79 auth_context->remote_addr + sizeof(krb5_address);
80 memcpy(auth_context->remote_addr->contents,
81 remote_addr->contents, remote_addr->length);
83 auth_context->remote_addr = NULL;
89 krb5_auth_con_getaddrs(context, auth_context, local_addr, remote_addr)
91 krb5_auth_context * auth_context;
92 krb5_address ** local_addr;
93 krb5_address ** remote_addr;
95 krb5_address * tmp_addr;
97 if (local_addr && auth_context->local_addr) {
98 if ((tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))) == NULL)
100 if (tmp_addr->contents = malloc(auth_context->local_addr->length)) {
101 memcpy(tmp_addr->contents, auth_context->local_addr->contents,
102 auth_context->local_addr->length);
103 tmp_addr->addrtype = auth_context->local_addr->addrtype;
104 tmp_addr->length = auth_context->local_addr->length;
105 *local_addr = tmp_addr;
111 if ((remote_addr) && auth_context->remote_addr) {
112 if ((tmp_addr = (krb5_address *)malloc(sizeof(krb5_address))) == NULL) {
113 if (local_addr && auth_context->local_addr) {
114 krb5_free_address(context, *local_addr);
118 if (tmp_addr->contents = malloc(auth_context->remote_addr->length)) {
119 memcpy(tmp_addr->contents, auth_context->remote_addr->contents,
120 auth_context->remote_addr->length);
121 tmp_addr->addrtype = auth_context->remote_addr->addrtype;
122 tmp_addr->length = auth_context->remote_addr->length;
123 *remote_addr = tmp_addr;
125 if (local_addr && auth_context->local_addr) {
126 krb5_free_address(context, *local_addr);
135 /* XXX this call is a hack. Fixed when I do the servers. */
137 krb5_auth_con_setkey(context, auth_context, keyblock)
138 krb5_context context;
139 krb5_auth_context * auth_context;
140 krb5_keyblock * keyblock;
142 if (auth_context->keyblock)
143 krb5_free_keyblock(context, auth_context->keyblock);
144 return(krb5_copy_keyblock(context, keyblock, &(auth_context->keyblock)));
148 * This function overloads the keyblock field. It is only useful prior to
149 * a krb5_rd_req_decode() call for user to user authentication where the
150 * server has the key and needs to use it to decrypt the incoming request.
151 * Once decrypted this key is no longer necessary and is then overwritten
152 * with the session key sent by the client.
155 krb5_auth_con_setuseruserkey(context, auth_context, keyblock)
156 krb5_context context;
157 krb5_auth_context * auth_context;
158 krb5_keyblock * keyblock;
160 if (auth_context->keyblock)
161 krb5_free_keyblock(context, auth_context->keyblock);
162 return(krb5_copy_keyblock(context, keyblock, &(auth_context->keyblock)));
166 krb5_auth_con_getkey(context, auth_context, keyblock)
167 krb5_context context;
168 krb5_auth_context * auth_context;
169 krb5_keyblock ** keyblock;
171 if (auth_context->keyblock)
172 return krb5_copy_keyblock(context, auth_context->keyblock, keyblock);
178 krb5_auth_con_getlocalsubkey(context, auth_context, keyblock)
179 krb5_context context;
180 krb5_auth_context * auth_context;
181 krb5_keyblock ** keyblock;
183 if (auth_context->local_subkey)
184 return krb5_copy_keyblock(context,auth_context->local_subkey,keyblock);
190 krb5_auth_con_getremotesubkey(context, auth_context, keyblock)
191 krb5_context context;
192 krb5_auth_context * auth_context;
193 krb5_keyblock ** keyblock;
195 if (auth_context->remote_subkey)
196 return krb5_copy_keyblock(context,auth_context->remote_subkey,keyblock);
202 krb5_auth_con_setcksumtype(context, auth_context, cksumtype)
203 krb5_context context;
204 krb5_auth_context * auth_context;
205 krb5_cksumtype cksumtype;
207 auth_context->cksumtype = cksumtype;
212 krb5_auth_con_getlocalseqnumber(context, auth_context, seqnumber)
213 krb5_context context;
214 krb5_auth_context * auth_context;
215 krb5_int32 * seqnumber;
217 *seqnumber = auth_context->local_seq_number;
222 krb5_auth_con_getauthenticator(context, auth_context, authenticator)
223 krb5_context context;
224 krb5_auth_context * auth_context;
225 krb5_authenticator ** authenticator;
227 return (krb5_copy_authenticator(context, auth_context->authentp,
232 krb5_auth_con_getremoteseqnumber(context, auth_context, seqnumber)
233 krb5_context context;
234 krb5_auth_context * auth_context;
235 krb5_int32 * seqnumber;
237 *seqnumber = auth_context->remote_seq_number;
242 krb5_auth_con_initivector(context, auth_context)
243 krb5_context context;
244 krb5_auth_context * auth_context;
246 if (auth_context->keyblock) {
247 int size = krb5_keytype_array[auth_context->keyblock->keytype]->
248 system->block_length;
250 if (auth_context->i_vector = (krb5_pointer)malloc(size)) {
251 memset(auth_context->i_vector, 0, size);
256 return EINVAL; /* XXX need an error for no keyblock */
260 krb5_auth_con_setivector(context, auth_context, ivector)
261 krb5_context context;
262 krb5_auth_context * auth_context;
263 krb5_pointer ivector;
265 auth_context->i_vector = ivector;
270 krb5_auth_con_getivector(context, auth_context, ivector)
271 krb5_context context;
272 krb5_auth_context * auth_context;
273 krb5_pointer * ivector;
275 *ivector = auth_context->i_vector;
280 krb5_auth_con_setflags(context, auth_context, flags)
281 krb5_context context;
282 krb5_auth_context * auth_context;
285 auth_context->auth_context_flags = flags;
290 krb5_auth_con_getflags(context, auth_context, flags)
291 krb5_context context;
292 krb5_auth_context * auth_context;
295 *flags = auth_context->auth_context_flags;
300 krb5_auth_con_setrcache(context, auth_context, rcache)
301 krb5_context context;
302 krb5_auth_context * auth_context;
305 auth_context->rcache = rcache;