1 1.1 elric /* $NetBSD: get_in_tkt.c,v 1.3 2019/12/15 22:50:50 christos Exp $ */ 2 1.1 elric 3 1.1 elric /* 4 1.1 elric * Copyright (c) 1997 - 2008 Kungliga Tekniska Hgskolan 5 1.1 elric * (Royal Institute of Technology, Stockholm, Sweden). 6 1.1 elric * All rights reserved. 7 1.1 elric * 8 1.1 elric * Redistribution and use in source and binary forms, with or without 9 1.1 elric * modification, are permitted provided that the following conditions 10 1.1 elric * are met: 11 1.1 elric * 12 1.1 elric * 1. Redistributions of source code must retain the above copyright 13 1.1 elric * notice, this list of conditions and the following disclaimer. 14 1.1 elric * 15 1.1 elric * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 elric * notice, this list of conditions and the following disclaimer in the 17 1.1 elric * documentation and/or other materials provided with the distribution. 18 1.1 elric * 19 1.1 elric * 3. Neither the name of the Institute nor the names of its contributors 20 1.1 elric * may be used to endorse or promote products derived from this software 21 1.1 elric * without specific prior written permission. 22 1.1 elric * 23 1.1 elric * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24 1.1 elric * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 1.1 elric * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 1.1 elric * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27 1.1 elric * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 1.1 elric * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 1.1 elric * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 1.1 elric * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 1.1 elric * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 1.1 elric * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 1.1 elric * SUCH DAMAGE. 34 1.1 elric */ 35 1.1 elric 36 1.2 christos #define KRB5_DEPRECATED_FUNCTION(x) 37 1.1 elric 38 1.1 elric #include "krb5_locl.h" 39 1.1 elric 40 1.1 elric #ifndef HEIMDAL_SMALLER 41 1.1 elric 42 1.1 elric static krb5_error_code 43 1.1 elric make_pa_enc_timestamp(krb5_context context, PA_DATA *pa, 44 1.1 elric krb5_enctype etype, krb5_keyblock *key) 45 1.1 elric { 46 1.1 elric PA_ENC_TS_ENC p; 47 1.1 elric unsigned char *buf; 48 1.1 elric size_t buf_size; 49 1.2 christos size_t len = 0; 50 1.1 elric EncryptedData encdata; 51 1.1 elric krb5_error_code ret; 52 1.1 elric int32_t usec; 53 1.1 elric int usec2; 54 1.1 elric krb5_crypto crypto; 55 1.1 elric 56 1.1 elric krb5_us_timeofday (context, &p.patimestamp, &usec); 57 1.1 elric usec2 = usec; 58 1.1 elric p.pausec = &usec2; 59 1.1 elric 60 1.1 elric ASN1_MALLOC_ENCODE(PA_ENC_TS_ENC, buf, buf_size, &p, &len, ret); 61 1.1 elric if (ret) 62 1.1 elric return ret; 63 1.1 elric if(buf_size != len) 64 1.1 elric krb5_abortx(context, "internal error in ASN.1 encoder"); 65 1.1 elric ret = krb5_crypto_init(context, key, 0, &crypto); 66 1.1 elric if (ret) { 67 1.1 elric free(buf); 68 1.1 elric return ret; 69 1.1 elric } 70 1.1 elric ret = krb5_encrypt_EncryptedData(context, 71 1.1 elric crypto, 72 1.1 elric KRB5_KU_PA_ENC_TIMESTAMP, 73 1.1 elric buf, 74 1.1 elric len, 75 1.1 elric 0, 76 1.1 elric &encdata); 77 1.1 elric free(buf); 78 1.1 elric krb5_crypto_destroy(context, crypto); 79 1.1 elric if (ret) 80 1.1 elric return ret; 81 1.2 christos 82 1.1 elric ASN1_MALLOC_ENCODE(EncryptedData, buf, buf_size, &encdata, &len, ret); 83 1.1 elric free_EncryptedData(&encdata); 84 1.1 elric if (ret) 85 1.1 elric return ret; 86 1.1 elric if(buf_size != len) 87 1.1 elric krb5_abortx(context, "internal error in ASN.1 encoder"); 88 1.1 elric pa->padata_type = KRB5_PADATA_ENC_TIMESTAMP; 89 1.1 elric pa->padata_value.length = len; 90 1.1 elric pa->padata_value.data = buf; 91 1.1 elric return 0; 92 1.1 elric } 93 1.1 elric 94 1.1 elric static krb5_error_code 95 1.1 elric add_padata(krb5_context context, 96 1.1 elric METHOD_DATA *md, 97 1.1 elric krb5_principal client, 98 1.1 elric krb5_key_proc key_proc, 99 1.1 elric krb5_const_pointer keyseed, 100 1.1 elric krb5_enctype *enctypes, 101 1.1 elric unsigned netypes, 102 1.1 elric krb5_salt *salt) 103 1.1 elric { 104 1.1 elric krb5_error_code ret; 105 1.1 elric PA_DATA *pa2; 106 1.1 elric krb5_salt salt2; 107 1.1 elric krb5_enctype *ep; 108 1.2 christos size_t i; 109 1.1 elric 110 1.1 elric if(salt == NULL) { 111 1.1 elric /* default to standard salt */ 112 1.1 elric ret = krb5_get_pw_salt (context, client, &salt2); 113 1.1 elric if (ret) 114 1.1 elric return ret; 115 1.1 elric salt = &salt2; 116 1.1 elric } 117 1.1 elric if (!enctypes) { 118 1.1 elric enctypes = context->etypes; 119 1.1 elric netypes = 0; 120 1.2 christos for (ep = enctypes; *ep != (krb5_enctype)ETYPE_NULL; ep++) 121 1.1 elric netypes++; 122 1.1 elric } 123 1.1 elric pa2 = realloc (md->val, (md->len + netypes) * sizeof(*md->val)); 124 1.2 christos if (pa2 == NULL) 125 1.2 christos return krb5_enomem(context); 126 1.1 elric md->val = pa2; 127 1.1 elric 128 1.1 elric for (i = 0; i < netypes; ++i) { 129 1.1 elric krb5_keyblock *key; 130 1.1 elric 131 1.1 elric ret = (*key_proc)(context, enctypes[i], *salt, keyseed, &key); 132 1.1 elric if (ret) 133 1.1 elric continue; 134 1.1 elric ret = make_pa_enc_timestamp (context, &md->val[md->len], 135 1.1 elric enctypes[i], key); 136 1.1 elric krb5_free_keyblock (context, key); 137 1.1 elric if (ret) 138 1.1 elric return ret; 139 1.1 elric ++md->len; 140 1.1 elric } 141 1.1 elric if(salt == &salt2) 142 1.1 elric krb5_free_salt(context, salt2); 143 1.1 elric return 0; 144 1.1 elric } 145 1.1 elric 146 1.1 elric static krb5_error_code 147 1.1 elric init_as_req (krb5_context context, 148 1.1 elric KDCOptions opts, 149 1.1 elric krb5_creds *creds, 150 1.1 elric const krb5_addresses *addrs, 151 1.1 elric const krb5_enctype *etypes, 152 1.1 elric const krb5_preauthtype *ptypes, 153 1.1 elric const krb5_preauthdata *preauth, 154 1.1 elric krb5_key_proc key_proc, 155 1.1 elric krb5_const_pointer keyseed, 156 1.1 elric unsigned nonce, 157 1.1 elric AS_REQ *a) 158 1.1 elric { 159 1.1 elric krb5_error_code ret; 160 1.1 elric krb5_salt salt; 161 1.1 elric 162 1.1 elric memset(a, 0, sizeof(*a)); 163 1.1 elric 164 1.1 elric a->pvno = 5; 165 1.1 elric a->msg_type = krb_as_req; 166 1.1 elric a->req_body.kdc_options = opts; 167 1.1 elric a->req_body.cname = malloc(sizeof(*a->req_body.cname)); 168 1.1 elric if (a->req_body.cname == NULL) { 169 1.2 christos ret = krb5_enomem(context); 170 1.1 elric goto fail; 171 1.1 elric } 172 1.1 elric a->req_body.sname = malloc(sizeof(*a->req_body.sname)); 173 1.1 elric if (a->req_body.sname == NULL) { 174 1.2 christos ret = krb5_enomem(context); 175 1.1 elric goto fail; 176 1.1 elric } 177 1.1 elric ret = _krb5_principal2principalname (a->req_body.cname, creds->client); 178 1.1 elric if (ret) 179 1.1 elric goto fail; 180 1.1 elric ret = _krb5_principal2principalname (a->req_body.sname, creds->server); 181 1.1 elric if (ret) 182 1.1 elric goto fail; 183 1.1 elric ret = copy_Realm(&creds->client->realm, &a->req_body.realm); 184 1.1 elric if (ret) 185 1.1 elric goto fail; 186 1.1 elric 187 1.1 elric if(creds->times.starttime) { 188 1.1 elric a->req_body.from = malloc(sizeof(*a->req_body.from)); 189 1.1 elric if (a->req_body.from == NULL) { 190 1.2 christos ret = krb5_enomem(context); 191 1.1 elric goto fail; 192 1.1 elric } 193 1.1 elric *a->req_body.from = creds->times.starttime; 194 1.1 elric } 195 1.1 elric if(creds->times.endtime){ 196 1.1 elric ALLOC(a->req_body.till, 1); 197 1.1 elric *a->req_body.till = creds->times.endtime; 198 1.1 elric } 199 1.1 elric if(creds->times.renew_till){ 200 1.1 elric a->req_body.rtime = malloc(sizeof(*a->req_body.rtime)); 201 1.1 elric if (a->req_body.rtime == NULL) { 202 1.2 christos ret = krb5_enomem(context); 203 1.1 elric goto fail; 204 1.1 elric } 205 1.1 elric *a->req_body.rtime = creds->times.renew_till; 206 1.1 elric } 207 1.1 elric a->req_body.nonce = nonce; 208 1.2 christos ret = _krb5_init_etype(context, 209 1.2 christos KRB5_PDU_AS_REQUEST, 210 1.1 elric &a->req_body.etype.len, 211 1.1 elric &a->req_body.etype.val, 212 1.1 elric etypes); 213 1.1 elric if (ret) 214 1.1 elric goto fail; 215 1.1 elric 216 1.1 elric /* 217 1.1 elric * This means no addresses 218 1.1 elric */ 219 1.1 elric 220 1.1 elric if (addrs && addrs->len == 0) { 221 1.1 elric a->req_body.addresses = NULL; 222 1.1 elric } else { 223 1.1 elric a->req_body.addresses = malloc(sizeof(*a->req_body.addresses)); 224 1.1 elric if (a->req_body.addresses == NULL) { 225 1.2 christos ret = krb5_enomem(context); 226 1.1 elric goto fail; 227 1.1 elric } 228 1.1 elric 229 1.1 elric if (addrs) 230 1.1 elric ret = krb5_copy_addresses(context, addrs, a->req_body.addresses); 231 1.1 elric else { 232 1.1 elric ret = krb5_get_all_client_addrs (context, a->req_body.addresses); 233 1.1 elric if(ret == 0 && a->req_body.addresses->len == 0) { 234 1.1 elric free(a->req_body.addresses); 235 1.1 elric a->req_body.addresses = NULL; 236 1.1 elric } 237 1.1 elric } 238 1.1 elric if (ret) 239 1.1 elric return ret; 240 1.1 elric } 241 1.1 elric 242 1.1 elric a->req_body.enc_authorization_data = NULL; 243 1.1 elric a->req_body.additional_tickets = NULL; 244 1.1 elric 245 1.1 elric if(preauth != NULL) { 246 1.2 christos size_t i; 247 1.1 elric ALLOC(a->padata, 1); 248 1.1 elric if(a->padata == NULL) { 249 1.2 christos ret = krb5_enomem(context); 250 1.1 elric goto fail; 251 1.1 elric } 252 1.1 elric a->padata->val = NULL; 253 1.1 elric a->padata->len = 0; 254 1.1 elric for(i = 0; i < preauth->len; i++) { 255 1.1 elric if(preauth->val[i].type == KRB5_PADATA_ENC_TIMESTAMP){ 256 1.2 christos size_t j; 257 1.1 elric 258 1.1 elric for(j = 0; j < preauth->val[i].info.len; j++) { 259 1.1 elric krb5_salt *sp = &salt; 260 1.1 elric if(preauth->val[i].info.val[j].salttype) 261 1.1 elric salt.salttype = *preauth->val[i].info.val[j].salttype; 262 1.1 elric else 263 1.1 elric salt.salttype = KRB5_PW_SALT; 264 1.1 elric if(preauth->val[i].info.val[j].salt) 265 1.1 elric salt.saltvalue = *preauth->val[i].info.val[j].salt; 266 1.1 elric else 267 1.1 elric if(salt.salttype == KRB5_PW_SALT) 268 1.1 elric sp = NULL; 269 1.1 elric else 270 1.1 elric krb5_data_zero(&salt.saltvalue); 271 1.1 elric ret = add_padata(context, a->padata, creds->client, 272 1.1 elric key_proc, keyseed, 273 1.1 elric &preauth->val[i].info.val[j].etype, 1, 274 1.1 elric sp); 275 1.1 elric if (ret == 0) 276 1.1 elric break; 277 1.1 elric } 278 1.1 elric } 279 1.1 elric } 280 1.1 elric } else 281 1.1 elric /* not sure this is the way to use `ptypes' */ 282 1.1 elric if (ptypes == NULL || *ptypes == KRB5_PADATA_NONE) 283 1.1 elric a->padata = NULL; 284 1.1 elric else if (*ptypes == KRB5_PADATA_ENC_TIMESTAMP) { 285 1.1 elric ALLOC(a->padata, 1); 286 1.1 elric if (a->padata == NULL) { 287 1.2 christos ret = krb5_enomem(context); 288 1.1 elric goto fail; 289 1.1 elric } 290 1.1 elric a->padata->len = 0; 291 1.1 elric a->padata->val = NULL; 292 1.1 elric 293 1.1 elric /* make a v5 salted pa-data */ 294 1.1 elric add_padata(context, a->padata, creds->client, 295 1.1 elric key_proc, keyseed, a->req_body.etype.val, 296 1.1 elric a->req_body.etype.len, NULL); 297 1.2 christos 298 1.1 elric /* make a v4 salted pa-data */ 299 1.1 elric salt.salttype = KRB5_PW_SALT; 300 1.1 elric krb5_data_zero(&salt.saltvalue); 301 1.1 elric add_padata(context, a->padata, creds->client, 302 1.1 elric key_proc, keyseed, a->req_body.etype.val, 303 1.1 elric a->req_body.etype.len, &salt); 304 1.1 elric } else { 305 1.1 elric ret = KRB5_PREAUTH_BAD_TYPE; 306 1.1 elric krb5_set_error_message (context, ret, 307 1.1 elric N_("pre-auth type %d not supported", ""), 308 1.1 elric *ptypes); 309 1.1 elric goto fail; 310 1.1 elric } 311 1.1 elric return 0; 312 1.1 elric fail: 313 1.1 elric free_AS_REQ(a); 314 1.1 elric return ret; 315 1.1 elric } 316 1.1 elric 317 1.1 elric static int 318 1.1 elric set_ptypes(krb5_context context, 319 1.1 elric KRB_ERROR *error, 320 1.1 elric const krb5_preauthtype **ptypes, 321 1.1 elric krb5_preauthdata **preauth) 322 1.1 elric { 323 1.1 elric static krb5_preauthdata preauth2; 324 1.1 elric static krb5_preauthtype ptypes2[] = { KRB5_PADATA_ENC_TIMESTAMP, KRB5_PADATA_NONE }; 325 1.1 elric 326 1.1 elric if(error->e_data) { 327 1.1 elric METHOD_DATA md; 328 1.2 christos size_t i; 329 1.1 elric decode_METHOD_DATA(error->e_data->data, 330 1.1 elric error->e_data->length, 331 1.1 elric &md, 332 1.1 elric NULL); 333 1.1 elric for(i = 0; i < md.len; i++){ 334 1.1 elric switch(md.val[i].padata_type){ 335 1.1 elric case KRB5_PADATA_ENC_TIMESTAMP: 336 1.1 elric *ptypes = ptypes2; 337 1.1 elric break; 338 1.1 elric case KRB5_PADATA_ETYPE_INFO: 339 1.1 elric *preauth = &preauth2; 340 1.1 elric ALLOC_SEQ(*preauth, 1); 341 1.1 elric (*preauth)->val[0].type = KRB5_PADATA_ENC_TIMESTAMP; 342 1.1 elric decode_ETYPE_INFO(md.val[i].padata_value.data, 343 1.1 elric md.val[i].padata_value.length, 344 1.1 elric &(*preauth)->val[0].info, 345 1.1 elric NULL); 346 1.1 elric break; 347 1.1 elric default: 348 1.1 elric break; 349 1.1 elric } 350 1.1 elric } 351 1.1 elric free_METHOD_DATA(&md); 352 1.1 elric } else { 353 1.1 elric *ptypes = ptypes2; 354 1.1 elric } 355 1.1 elric return(1); 356 1.1 elric } 357 1.1 elric 358 1.1 elric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL 359 1.1 elric krb5_get_in_cred(krb5_context context, 360 1.1 elric krb5_flags options, 361 1.1 elric const krb5_addresses *addrs, 362 1.1 elric const krb5_enctype *etypes, 363 1.1 elric const krb5_preauthtype *ptypes, 364 1.1 elric const krb5_preauthdata *preauth, 365 1.1 elric krb5_key_proc key_proc, 366 1.1 elric krb5_const_pointer keyseed, 367 1.1 elric krb5_decrypt_proc decrypt_proc, 368 1.1 elric krb5_const_pointer decryptarg, 369 1.1 elric krb5_creds *creds, 370 1.1 elric krb5_kdc_rep *ret_as_reply) 371 1.2 christos KRB5_DEPRECATED_FUNCTION("Use X instead") 372 1.1 elric { 373 1.1 elric krb5_error_code ret; 374 1.1 elric AS_REQ a; 375 1.1 elric krb5_kdc_rep rep; 376 1.1 elric krb5_data req, resp; 377 1.2 christos size_t len = 0; 378 1.1 elric krb5_salt salt; 379 1.1 elric krb5_keyblock *key; 380 1.1 elric size_t size; 381 1.1 elric KDCOptions opts; 382 1.1 elric PA_DATA *pa; 383 1.1 elric krb5_enctype etype; 384 1.1 elric krb5_preauthdata *my_preauth = NULL; 385 1.1 elric unsigned nonce; 386 1.1 elric int done; 387 1.1 elric 388 1.1 elric opts = int2KDCOptions(options); 389 1.1 elric 390 1.1 elric krb5_generate_random_block (&nonce, sizeof(nonce)); 391 1.1 elric nonce &= 0xffffffff; 392 1.1 elric 393 1.1 elric do { 394 1.1 elric done = 1; 395 1.1 elric ret = init_as_req (context, 396 1.1 elric opts, 397 1.1 elric creds, 398 1.1 elric addrs, 399 1.1 elric etypes, 400 1.1 elric ptypes, 401 1.1 elric preauth, 402 1.1 elric key_proc, 403 1.1 elric keyseed, 404 1.1 elric nonce, 405 1.1 elric &a); 406 1.1 elric if (my_preauth) { 407 1.1 elric free_ETYPE_INFO(&my_preauth->val[0].info); 408 1.1 elric free (my_preauth->val); 409 1.1 elric my_preauth = NULL; 410 1.1 elric } 411 1.1 elric if (ret) 412 1.1 elric return ret; 413 1.1 elric 414 1.1 elric ASN1_MALLOC_ENCODE(AS_REQ, req.data, req.length, &a, &len, ret); 415 1.1 elric free_AS_REQ(&a); 416 1.1 elric if (ret) 417 1.1 elric return ret; 418 1.1 elric if(len != req.length) 419 1.1 elric krb5_abortx(context, "internal error in ASN.1 encoder"); 420 1.1 elric 421 1.1 elric ret = krb5_sendto_kdc (context, &req, &creds->client->realm, &resp); 422 1.1 elric krb5_data_free(&req); 423 1.1 elric if (ret) 424 1.1 elric return ret; 425 1.1 elric 426 1.1 elric memset (&rep, 0, sizeof(rep)); 427 1.1 elric ret = decode_AS_REP(resp.data, resp.length, &rep.kdc_rep, &size); 428 1.1 elric if(ret) { 429 1.1 elric /* let's try to parse it as a KRB-ERROR */ 430 1.1 elric KRB_ERROR error; 431 1.1 elric int ret2; 432 1.1 elric 433 1.1 elric ret2 = krb5_rd_error(context, &resp, &error); 434 1.1 elric if(ret2 && resp.data && ((char*)resp.data)[0] == 4) 435 1.1 elric ret = KRB5KRB_AP_ERR_V4_REPLY; 436 1.1 elric krb5_data_free(&resp); 437 1.1 elric if (ret2 == 0) { 438 1.1 elric ret = krb5_error_from_rd_error(context, &error, creds); 439 1.1 elric /* if no preauth was set and KDC requires it, give it 440 1.1 elric one more try */ 441 1.1 elric if (!ptypes && !preauth 442 1.1 elric && ret == KRB5KDC_ERR_PREAUTH_REQUIRED 443 1.1 elric #if 0 444 1.1 elric || ret == KRB5KDC_ERR_BADOPTION 445 1.1 elric #endif 446 1.1 elric && set_ptypes(context, &error, &ptypes, &my_preauth)) { 447 1.1 elric done = 0; 448 1.1 elric preauth = my_preauth; 449 1.1 elric krb5_free_error_contents(context, &error); 450 1.1 elric krb5_clear_error_message(context); 451 1.1 elric continue; 452 1.1 elric } 453 1.1 elric if(ret_as_reply) 454 1.1 elric ret_as_reply->error = error; 455 1.1 elric else 456 1.1 elric free_KRB_ERROR (&error); 457 1.1 elric return ret; 458 1.1 elric } 459 1.1 elric return ret; 460 1.1 elric } 461 1.1 elric krb5_data_free(&resp); 462 1.1 elric } while(!done); 463 1.1 elric 464 1.1 elric pa = NULL; 465 1.1 elric etype = rep.kdc_rep.enc_part.etype; 466 1.1 elric if(rep.kdc_rep.padata){ 467 1.1 elric int i = 0; 468 1.1 elric pa = krb5_find_padata(rep.kdc_rep.padata->val, rep.kdc_rep.padata->len, 469 1.1 elric KRB5_PADATA_PW_SALT, &i); 470 1.1 elric if(pa == NULL) { 471 1.1 elric i = 0; 472 1.1 elric pa = krb5_find_padata(rep.kdc_rep.padata->val, 473 1.1 elric rep.kdc_rep.padata->len, 474 1.1 elric KRB5_PADATA_AFS3_SALT, &i); 475 1.1 elric } 476 1.1 elric } 477 1.1 elric if(pa) { 478 1.2 christos salt.salttype = (krb5_salttype)pa->padata_type; 479 1.1 elric salt.saltvalue = pa->padata_value; 480 1.2 christos 481 1.1 elric ret = (*key_proc)(context, etype, salt, keyseed, &key); 482 1.1 elric } else { 483 1.1 elric /* make a v5 salted pa-data */ 484 1.1 elric ret = krb5_get_pw_salt (context, creds->client, &salt); 485 1.2 christos 486 1.1 elric if (ret) 487 1.1 elric goto out; 488 1.1 elric ret = (*key_proc)(context, etype, salt, keyseed, &key); 489 1.1 elric krb5_free_salt(context, salt); 490 1.1 elric } 491 1.1 elric if (ret) 492 1.1 elric goto out; 493 1.2 christos 494 1.1 elric { 495 1.1 elric unsigned flags = EXTRACT_TICKET_TIMESYNC; 496 1.1 elric if (opts.request_anonymous) 497 1.3 christos flags |= EXTRACT_TICKET_ALLOW_SERVER_MISMATCH | EXTRACT_TICKET_MATCH_ANON; 498 1.1 elric 499 1.1 elric ret = _krb5_extract_ticket(context, 500 1.1 elric &rep, 501 1.1 elric creds, 502 1.1 elric key, 503 1.1 elric keyseed, 504 1.1 elric KRB5_KU_AS_REP_ENC_PART, 505 1.1 elric NULL, 506 1.1 elric nonce, 507 1.1 elric flags, 508 1.2 christos NULL, 509 1.1 elric decrypt_proc, 510 1.1 elric decryptarg); 511 1.1 elric } 512 1.1 elric memset (key->keyvalue.data, 0, key->keyvalue.length); 513 1.1 elric krb5_free_keyblock_contents (context, key); 514 1.1 elric free (key); 515 1.1 elric 516 1.1 elric out: 517 1.1 elric if (ret == 0 && ret_as_reply) 518 1.1 elric *ret_as_reply = rep; 519 1.1 elric else 520 1.1 elric krb5_free_kdc_rep (context, &rep); 521 1.1 elric return ret; 522 1.1 elric } 523 1.1 elric 524 1.1 elric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL 525 1.1 elric krb5_get_in_tkt(krb5_context context, 526 1.1 elric krb5_flags options, 527 1.1 elric const krb5_addresses *addrs, 528 1.1 elric const krb5_enctype *etypes, 529 1.1 elric const krb5_preauthtype *ptypes, 530 1.1 elric krb5_key_proc key_proc, 531 1.1 elric krb5_const_pointer keyseed, 532 1.1 elric krb5_decrypt_proc decrypt_proc, 533 1.1 elric krb5_const_pointer decryptarg, 534 1.1 elric krb5_creds *creds, 535 1.1 elric krb5_ccache ccache, 536 1.1 elric krb5_kdc_rep *ret_as_reply) 537 1.2 christos KRB5_DEPRECATED_FUNCTION("Use X instead") 538 1.1 elric { 539 1.1 elric krb5_error_code ret; 540 1.1 elric 541 1.1 elric ret = krb5_get_in_cred (context, 542 1.1 elric options, 543 1.1 elric addrs, 544 1.1 elric etypes, 545 1.1 elric ptypes, 546 1.1 elric NULL, 547 1.1 elric key_proc, 548 1.1 elric keyseed, 549 1.1 elric decrypt_proc, 550 1.1 elric decryptarg, 551 1.1 elric creds, 552 1.1 elric ret_as_reply); 553 1.1 elric if(ret) 554 1.1 elric return ret; 555 1.1 elric if (ccache) 556 1.1 elric ret = krb5_cc_store_cred (context, ccache, creds); 557 1.1 elric return ret; 558 1.1 elric } 559 1.1 elric 560 1.1 elric #endif /* HEIMDAL_SMALLER */ 561