3 * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
4 * (Royal Institute of Technology, Stockholm, Sweden).
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the Institute nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include "krb5_locl.h"
37 static krb5_error_code
38 decrypt_tkt_enc_part (krb5_context context,
40 EncryptedData *enc_part,
41 EncTicketPart *decr_part)
48 ret = krb5_crypto_init(context, key, 0, &crypto);
51 ret = krb5_decrypt_EncryptedData (context,
56 krb5_crypto_destroy(context, crypto);
60 ret = decode_EncTicketPart(plain.data, plain.length, decr_part, &len);
62 krb5_set_error_message(context, ret,
63 N_("Failed to decode encrypted "
65 krb5_data_free (&plain);
69 static krb5_error_code
70 decrypt_authenticator (krb5_context context,
72 EncryptedData *enc_part,
73 Authenticator *authenticator,
81 ret = krb5_crypto_init(context, key, 0, &crypto);
84 ret = krb5_decrypt_EncryptedData (context,
86 usage /* KRB5_KU_AP_REQ_AUTH */,
89 /* for backwards compatibility, also try the old usage */
90 if (ret && usage == KRB5_KU_TGS_REQ_AUTH)
91 ret = krb5_decrypt_EncryptedData (context,
96 krb5_crypto_destroy(context, crypto);
100 ret = decode_Authenticator(plain.data, plain.length,
101 authenticator, &len);
102 krb5_data_free (&plain);
106 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
107 krb5_decode_ap_req(krb5_context context,
108 const krb5_data *inbuf,
113 ret = decode_AP_REQ(inbuf->data, inbuf->length, ap_req, &len);
116 if (ap_req->pvno != 5){
118 krb5_clear_error_message (context);
119 return KRB5KRB_AP_ERR_BADVERSION;
121 if (ap_req->msg_type != krb_ap_req){
123 krb5_clear_error_message (context);
124 return KRB5KRB_AP_ERR_MSG_TYPE;
126 if (ap_req->ticket.tkt_vno != 5){
128 krb5_clear_error_message (context);
129 return KRB5KRB_AP_ERR_BADVERSION;
134 static krb5_error_code
135 check_transited(krb5_context context, Ticket *ticket, EncTicketPart *enc)
138 unsigned int num_realms, n;
142 * Windows 2000 and 2003 uses this inside their TGT so it's normaly
143 * not seen by others, however, samba4 joined with a Windows AD as
144 * a Domain Controller gets exposed to this.
146 if(enc->transited.tr_type == 0 && enc->transited.contents.length == 0)
149 if(enc->transited.tr_type != DOMAIN_X500_COMPRESS)
150 return KRB5KDC_ERR_TRTYPE_NOSUPP;
152 if(enc->transited.contents.length == 0)
155 ret = krb5_domain_x500_decode(context, enc->transited.contents,
156 &realms, &num_realms,
161 ret = krb5_check_transited(context, enc->crealm,
163 realms, num_realms, NULL);
164 for (n = 0; n < num_realms; n++)
170 static krb5_error_code
171 find_etypelist(krb5_context context,
172 krb5_auth_context auth_context,
177 krb5_authdata adIfRelevant;
180 memset(&adIfRelevant, 0, sizeof(adIfRelevant));
185 ad = auth_context->authenticator->authorization_data;
189 for (i = 0; i < ad->len; i++) {
190 if (ad->val[i].ad_type == KRB5_AUTHDATA_IF_RELEVANT) {
191 ret = decode_AD_IF_RELEVANT(ad->val[i].ad_data.data,
192 ad->val[i].ad_data.length,
198 if (adIfRelevant.len == 1 &&
199 adIfRelevant.val[0].ad_type ==
200 KRB5_AUTHDATA_GSS_API_ETYPE_NEGOTIATION) {
203 free_AD_IF_RELEVANT(&adIfRelevant);
204 adIfRelevant.len = 0;
208 if (adIfRelevant.len == 0)
211 ret = decode_EtypeList(adIfRelevant.val[0].ad_data.data,
212 adIfRelevant.val[0].ad_data.length,
216 krb5_clear_error_message(context);
218 free_AD_IF_RELEVANT(&adIfRelevant);
223 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
224 krb5_decrypt_ticket(krb5_context context,
232 ret = decrypt_tkt_enc_part (context, key, &ticket->enc_part, &t);
238 time_t start = t.authtime;
240 krb5_timeofday (context, &now);
242 start = *t.starttime;
243 if(start - now > context->max_skew
245 && !(flags & KRB5_VERIFY_AP_REQ_IGNORE_INVALID))) {
246 free_EncTicketPart(&t);
247 krb5_clear_error_message (context);
248 return KRB5KRB_AP_ERR_TKT_NYV;
250 if(now - t.endtime > context->max_skew) {
251 free_EncTicketPart(&t);
252 krb5_clear_error_message (context);
253 return KRB5KRB_AP_ERR_TKT_EXPIRED;
256 if(!t.flags.transited_policy_checked
257 && !(flags & KRB5_VERIFY_AP_REQ_NO_TRANSITED_CHECK)) {
258 ret = check_transited(context, ticket, &t);
260 free_EncTicketPart(&t);
269 free_EncTicketPart(&t);
273 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
274 krb5_verify_authenticator_checksum(krb5_context context,
275 krb5_auth_context ac,
281 krb5_authenticator authenticator;
284 ret = krb5_auth_con_getauthenticator (context,
289 if(authenticator->cksum == NULL) {
290 krb5_free_authenticator(context, &authenticator);
293 ret = krb5_auth_con_getkey(context, ac, &key);
295 krb5_free_authenticator(context, &authenticator);
298 ret = krb5_crypto_init(context, key, 0, &crypto);
301 ret = krb5_verify_checksum (context,
303 KRB5_KU_AP_REQ_AUTH_CKSUM,
306 authenticator->cksum);
307 krb5_crypto_destroy(context, crypto);
309 krb5_free_authenticator(context, &authenticator);
310 krb5_free_keyblock(context, key);
315 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
316 krb5_verify_ap_req(krb5_context context,
317 krb5_auth_context *auth_context,
319 krb5_const_principal server,
320 krb5_keyblock *keyblock,
322 krb5_flags *ap_req_options,
323 krb5_ticket **ticket)
325 return krb5_verify_ap_req2 (context,
333 KRB5_KU_AP_REQ_AUTH);
336 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
337 krb5_verify_ap_req2(krb5_context context,
338 krb5_auth_context *auth_context,
340 krb5_const_principal server,
341 krb5_keyblock *keyblock,
343 krb5_flags *ap_req_options,
344 krb5_ticket **ticket,
345 krb5_key_usage usage)
348 krb5_auth_context ac;
355 if (auth_context && *auth_context) {
358 ret = krb5_auth_con_init (context, &ac);
363 t = calloc(1, sizeof(*t));
366 krb5_clear_error_message (context);
370 if (ap_req->ap_options.use_session_key && ac->keyblock){
371 ret = krb5_decrypt_ticket(context, &ap_req->ticket,
375 krb5_free_keyblock(context, ac->keyblock);
378 ret = krb5_decrypt_ticket(context, &ap_req->ticket,
386 ret = _krb5_principalname2krb5_principal(context,
388 ap_req->ticket.sname,
389 ap_req->ticket.realm);
391 ret = _krb5_principalname2krb5_principal(context,
397 ret = decrypt_authenticator (context,
399 &ap_req->authenticator,
406 krb5_principal p1, p2;
409 _krb5_principalname2krb5_principal(context,
411 ac->authenticator->cname,
412 ac->authenticator->crealm);
413 _krb5_principalname2krb5_principal(context,
417 res = krb5_principal_compare (context, p1, p2);
418 krb5_free_principal (context, p1);
419 krb5_free_principal (context, p2);
421 ret = KRB5KRB_AP_ERR_BADMATCH;
422 krb5_clear_error_message (context);
427 /* check addresses */
430 && ac->remote_address
431 && !krb5_address_search (context,
434 ret = KRB5KRB_AP_ERR_BADADDR;
435 krb5_clear_error_message (context);
439 /* check timestamp in authenticator */
443 krb5_timeofday (context, &now);
445 if (abs(ac->authenticator->ctime - now) > context->max_skew) {
446 ret = KRB5KRB_AP_ERR_SKEW;
447 krb5_clear_error_message (context);
452 if (ac->authenticator->seq_number)
453 krb5_auth_con_setremoteseqnumber(context, ac,
454 *ac->authenticator->seq_number);
456 /* XXX - Xor sequence numbers */
458 if (ac->authenticator->subkey) {
459 ret = krb5_auth_con_setremotesubkey(context, ac,
460 ac->authenticator->subkey);
465 ret = find_etypelist(context, ac, &etypes);
469 ac->keytype = ETYPE_NULL;
474 for (i = 0; i < etypes.len; i++) {
475 if (krb5_enctype_valid(context, etypes.val[i]) == 0) {
476 ac->keytype = etypes.val[i];
483 ret = krb5_copy_keyblock(context, &t->ticket.key, &ac->keyblock);
486 if (ap_req_options) {
488 if (ac->keytype != ETYPE_NULL)
489 *ap_req_options |= AP_OPTS_USE_SUBKEY;
490 if (ap_req->ap_options.use_session_key)
491 *ap_req_options |= AP_OPTS_USE_SESSION_KEY;
492 if (ap_req->ap_options.mutual_required)
493 *ap_req_options |= AP_OPTS_MUTUAL_REQUIRED;
499 krb5_free_ticket (context, t);
501 if (*auth_context == NULL)
504 krb5_auth_con_free (context, ac);
505 free_EtypeList(&etypes);
509 krb5_free_ticket (context, t);
510 if (auth_context == NULL || *auth_context == NULL)
511 krb5_auth_con_free (context, ac);
519 struct krb5_rd_req_in_ctx_data {
521 krb5_boolean iterate_keytab;
522 krb5_keyblock *keyblock;
523 krb5_boolean check_pac;
524 krb5_flags verify_ap_req_flags;
527 struct krb5_rd_req_out_ctx_data {
528 krb5_keyblock *keyblock;
529 krb5_flags ap_req_options;
531 krb5_principal server;
535 * Allocate a krb5_rd_req_in_ctx as an input parameter to
536 * krb5_rd_req_ctx(). The caller should free the context with
537 * krb5_rd_req_in_ctx_free() when done with the context.
539 * @param context Keberos 5 context.
540 * @param ctx in ctx to krb5_rd_req_ctx().
542 * @return Kerberos 5 error code, see krb5_get_error_message().
547 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
548 krb5_rd_req_in_ctx_alloc(krb5_context context, krb5_rd_req_in_ctx *ctx)
550 *ctx = calloc(1, sizeof(**ctx));
552 krb5_set_error_message(context, ENOMEM,
553 N_("malloc: out of memory", ""));
556 (*ctx)->check_pac = (context->flags & KRB5_CTX_F_CHECK_PAC) ? 1 : 0;
561 * Set the keytab that krb5_rd_req_ctx() will use.
563 * @param context Keberos 5 context.
564 * @param in in ctx to krb5_rd_req_ctx().
565 * @param keytab keytab that krb5_rd_req_ctx() will use, only copy the
566 * pointer, so the caller must free they keytab after
567 * krb5_rd_req_in_ctx_free() is called.
569 * @return Kerberos 5 error code, see krb5_get_error_message().
574 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
575 krb5_rd_req_in_set_keytab(krb5_context context,
576 krb5_rd_req_in_ctx in,
583 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
584 krb5_rd_req_in_set_verify_ap_req_flags(krb5_context context,
585 krb5_rd_req_in_ctx in,
588 in->verify_ap_req_flags = flags;
593 * Set if krb5_rq_red() is going to iterate the keytab to find a key
595 * @param context Keberos 5 context.
596 * @param in krb5_rd_req_in_ctx to check the option on.
597 * @param flag flag to select if the keytab should be iterated (TRUE) or not (FALSE).
599 * @return Kerberos 5 error code, see krb5_get_error_message().
604 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
605 krb5_rd_req_in_set_iterate_keytab(krb5_context context,
606 krb5_rd_req_in_ctx in,
609 in->iterate_keytab = flag;
614 * Set if krb5_rq_red() is going to check the Windows PAC or not
616 * @param context Keberos 5 context.
617 * @param in krb5_rd_req_in_ctx to check the option on.
618 * @param flag flag to select if to check the pac (TRUE) or not (FALSE).
620 * @return Kerberos 5 error code, see krb5_get_error_message().
625 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
626 krb5_rd_req_in_set_pac_check(krb5_context context,
627 krb5_rd_req_in_ctx in,
630 in->check_pac = flag;
635 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
636 krb5_rd_req_in_set_keyblock(krb5_context context,
637 krb5_rd_req_in_ctx in,
638 krb5_keyblock *keyblock)
640 in->keyblock = keyblock; /* XXX should make copy */
644 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
645 krb5_rd_req_out_get_ap_req_options(krb5_context context,
646 krb5_rd_req_out_ctx out,
647 krb5_flags *ap_req_options)
649 *ap_req_options = out->ap_req_options;
653 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
654 krb5_rd_req_out_get_ticket(krb5_context context,
655 krb5_rd_req_out_ctx out,
656 krb5_ticket **ticket)
658 return krb5_copy_ticket(context, out->ticket, ticket);
661 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
662 krb5_rd_req_out_get_keyblock(krb5_context context,
663 krb5_rd_req_out_ctx out,
664 krb5_keyblock **keyblock)
666 return krb5_copy_keyblock(context, out->keyblock, keyblock);
670 * Get the principal that was used in the request from the
671 * client. Might not match whats in the ticket if krb5_rd_req_ctx()
672 * searched in the keytab for a matching key.
674 * @param context a Kerberos 5 context.
675 * @param out a krb5_rd_req_out_ctx from krb5_rd_req_ctx().
676 * @param principal return principal, free with krb5_free_principal().
681 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
682 krb5_rd_req_out_get_server(krb5_context context,
683 krb5_rd_req_out_ctx out,
684 krb5_principal *principal)
686 return krb5_copy_principal(context, out->server, principal);
689 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
690 krb5_rd_req_in_ctx_free(krb5_context context, krb5_rd_req_in_ctx ctx)
696 * Free the krb5_rd_req_out_ctx.
698 * @param context Keberos 5 context.
699 * @param ctx krb5_rd_req_out_ctx context to free.
704 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
705 krb5_rd_req_out_ctx_free(krb5_context context, krb5_rd_req_out_ctx ctx)
708 krb5_free_ticket(context, ctx->ticket);
710 krb5_free_keyblock(context, ctx->keyblock);
712 krb5_free_principal(context, ctx->server);
720 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
721 krb5_rd_req(krb5_context context,
722 krb5_auth_context *auth_context,
723 const krb5_data *inbuf,
724 krb5_const_principal server,
726 krb5_flags *ap_req_options,
727 krb5_ticket **ticket)
730 krb5_rd_req_in_ctx in;
731 krb5_rd_req_out_ctx out;
733 ret = krb5_rd_req_in_ctx_alloc(context, &in);
737 ret = krb5_rd_req_in_set_keytab(context, in, keytab);
739 krb5_rd_req_in_ctx_free(context, in);
743 ret = krb5_rd_req_ctx(context, auth_context, inbuf, server, in, &out);
744 krb5_rd_req_in_ctx_free(context, in);
749 *ap_req_options = out->ap_req_options;
751 ret = krb5_copy_ticket(context, out->ticket, ticket);
757 krb5_rd_req_out_ctx_free(context, out);
765 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
766 krb5_rd_req_with_keyblock(krb5_context context,
767 krb5_auth_context *auth_context,
768 const krb5_data *inbuf,
769 krb5_const_principal server,
770 krb5_keyblock *keyblock,
771 krb5_flags *ap_req_options,
772 krb5_ticket **ticket)
775 krb5_rd_req_in_ctx in;
776 krb5_rd_req_out_ctx out;
778 ret = krb5_rd_req_in_ctx_alloc(context, &in);
782 ret = krb5_rd_req_in_set_keyblock(context, in, keyblock);
784 krb5_rd_req_in_ctx_free(context, in);
788 ret = krb5_rd_req_ctx(context, auth_context, inbuf, server, in, &out);
789 krb5_rd_req_in_ctx_free(context, in);
794 *ap_req_options = out->ap_req_options;
796 ret = krb5_copy_ticket(context, out->ticket, ticket);
802 krb5_rd_req_out_ctx_free(context, out);
810 static krb5_error_code
811 get_key_from_keytab(krb5_context context,
813 krb5_const_principal server,
815 krb5_keyblock **out_key)
817 krb5_keytab_entry entry;
820 krb5_keytab real_keytab;
823 krb5_kt_default(context, &real_keytab);
825 real_keytab = keytab;
827 if (ap_req->ticket.enc_part.kvno)
828 kvno = *ap_req->ticket.enc_part.kvno;
832 ret = krb5_kt_get_entry (context,
836 ap_req->ticket.enc_part.etype,
840 ret = krb5_copy_keyblock(context, &entry.keyblock, out_key);
841 krb5_kt_free_entry (context, &entry);
844 krb5_kt_close(context, real_keytab);
850 * The core server function that verify application authentication
851 * requests from clients.
853 * @param context Keberos 5 context.
854 * @param auth_context the authentication context, can be NULL, then
855 * default values for the authentication context will used.
856 * @param inbuf the (AP-REQ) authentication buffer
858 * @param server the server with authenticate as, if NULL the function
859 * will try to find any available credential in the keytab
860 * that will verify the reply. The function will prefer the
861 * server the server client specified in the AP-REQ, but if
862 * there is no mach, it will try all keytab entries for a
863 * match. This have serious performance issues for larger keytabs.
865 * @param inctx control the behavior of the function, if NULL, the
866 * default behavior is used.
867 * @param outctx the return outctx, free with krb5_rd_req_out_ctx_free().
868 * @return Kerberos 5 error code, see krb5_get_error_message().
873 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
874 krb5_rd_req_ctx(krb5_context context,
875 krb5_auth_context *auth_context,
876 const krb5_data *inbuf,
877 krb5_const_principal server,
878 krb5_rd_req_in_ctx inctx,
879 krb5_rd_req_out_ctx *outctx)
883 krb5_rd_req_out_ctx o = NULL;
884 krb5_keytab id = NULL, keytab = NULL;
885 krb5_principal service = NULL;
886 krb5_flags verify_ap_req_flags = 0;
890 o = calloc(1, sizeof(*o));
892 krb5_set_error_message(context, ENOMEM,
893 N_("malloc: out of memory", ""));
897 if (*auth_context == NULL) {
898 ret = krb5_auth_con_init(context, auth_context);
903 ret = krb5_decode_ap_req(context, inbuf, &ap_req);
907 /* Save that principal that was in the request */
908 ret = _krb5_principalname2krb5_principal(context,
911 ap_req.ticket.realm);
915 if (ap_req.ap_options.use_session_key &&
916 (*auth_context)->keyblock == NULL) {
917 ret = KRB5KRB_AP_ERR_NOKEY;
918 krb5_set_error_message(context, ret,
919 N_("krb5_rd_req: user to user auth "
920 "without session key given", ""));
924 if (inctx && inctx->keytab)
928 verify_ap_req_flags = inctx->verify_ap_req_flags;
930 if((*auth_context)->keyblock){
931 ret = krb5_copy_keyblock(context,
932 (*auth_context)->keyblock,
936 } else if(inctx && inctx->keyblock){
937 ret = krb5_copy_keyblock(context,
942 } else if (id && inctx && inctx->iterate_keytab) {
944 * Force iterating over the keytab.
950 krb5_kt_default(context, &keytab);
956 if (server == NULL) {
957 ret = _krb5_principalname2krb5_principal(context,
960 ap_req.ticket.realm);
966 ret = get_key_from_keytab(context,
972 /* If caller specified a server, fail. */
973 if (service == NULL && (context->flags & KRB5_CTX_F_RD_REQ_IGNORE) == 0)
975 /* Otherwise, fall back to iterating over the keytab. This
976 * have serious performace issues for larger keytab.
984 * We got an exact keymatch, use that.
987 ret = krb5_verify_ap_req2(context,
995 KRB5_KU_AP_REQ_AUTH);
1002 * Interate over keytab to find a key that can decrypt the request.
1005 krb5_keytab_entry entry;
1006 krb5_kt_cursor cursor;
1007 int done = 0, kvno = 0;
1009 memset(&cursor, 0, sizeof(cursor));
1011 if (ap_req.ticket.enc_part.kvno)
1012 kvno = *ap_req.ticket.enc_part.kvno;
1014 ret = krb5_kt_start_seq_get(context, id, &cursor);
1022 ret = krb5_kt_next_entry(context, id, &entry, &cursor);
1024 _krb5_kt_principal_not_found(context, ret, id, o->server,
1025 ap_req.ticket.enc_part.etype,
1030 if (entry.keyblock.keytype != ap_req.ticket.enc_part.etype) {
1031 krb5_kt_free_entry (context, &entry);
1035 ret = krb5_verify_ap_req2(context,
1040 verify_ap_req_flags,
1043 KRB5_KU_AP_REQ_AUTH);
1044 if (ret == KRB5KRB_AP_ERR_BAD_INTEGRITY) {
1045 /* failed to decrypt, try the next key */
1046 krb5_kt_free_entry (context, &entry);
1050 krb5_kt_free_entry (context, &entry);
1055 * Found a match, save the keyblock for PAC processing,
1056 * and update the service principal in the ticket to match
1057 * whatever is in the keytab.
1060 ret = krb5_copy_keyblock(context,
1064 krb5_kt_free_entry (context, &entry);
1068 ret = krb5_copy_principal(context, entry.principal, &p);
1070 krb5_kt_free_entry (context, &entry);
1073 krb5_free_principal(context, o->ticket->server);
1074 o->ticket->server = p;
1076 krb5_kt_free_entry (context, &entry);
1080 krb5_kt_end_seq_get (context, id, &cursor);
1083 /* If there is a PAC, verify its server signature */
1084 if (inctx == NULL || inctx->check_pac) {
1088 ret = krb5_ticket_get_authorization_data_type(context,
1090 KRB5_AUTHDATA_WIN2K_PAC,
1093 ret = krb5_pac_parse(context, data.data, data.length, &pac);
1094 krb5_data_free(&data);
1098 ret = krb5_pac_verify(context,
1100 o->ticket->ticket.authtime,
1104 krb5_pac_free(context, pac);
1112 if (ret || outctx == NULL) {
1113 krb5_rd_req_out_ctx_free(context, o);
1117 free_AP_REQ(&ap_req);
1120 krb5_free_principal(context, service);
1123 krb5_kt_close(context, keytab);