2 * Copyright (c) 1997-2011 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Portions Copyright (c) 2010 - 2011 Apple Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static krb5_error_code
39 salt_fastuser_crypto(astgs_request_t r
,
40 krb5_const_principal salt_principal
,
42 krb5_crypto fast_crypto
,
43 krb5_crypto
*salted_crypto
)
46 krb5_principal client_princ
= NULL
;
51 *salted_crypto
= NULL
;
53 krb5_data_zero(&salt
);
54 krb5_keyblock_zero(&dkey
);
56 if (salt_principal
== NULL
) {
57 if (r
->req
.req_body
.cname
== NULL
) {
58 ret
= KRB5KRB_ERR_GENERIC
;
62 ret
= _krb5_principalname2krb5_principal(r
->context
, &client_princ
,
63 *(r
->req
.req_body
.cname
),
64 r
->req
.req_body
.realm
);
68 salt_principal
= client_princ
;
71 ret
= krb5_unparse_name(r
->context
, salt_principal
, (char **)&salt
.data
);
75 salt
.length
= strlen(salt
.data
);
77 kdc_log(r
->context
, r
->config
, 10,
78 "salt_fastuser_crypto: salt principal is %s (%d)",
79 (char *)salt
.data
, enctype
);
81 ret
= krb5_enctype_keysize(r
->context
, enctype
, &size
);
85 ret
= krb5_crypto_prfplus(r
->context
, fast_crypto
, &salt
,
86 size
, &dkey
.keyvalue
);
90 dkey
.keytype
= enctype
;
92 ret
= krb5_crypto_init(r
->context
, &dkey
, ENCTYPE_NULL
, salted_crypto
);
97 krb5_free_keyblock_contents(r
->context
, &dkey
);
98 krb5_data_free(&salt
);
99 krb5_free_principal(r
->context
, client_princ
);
104 static krb5_error_code
105 get_fastuser_crypto(astgs_request_t r
,
106 krb5_const_principal ticket_client
,
107 krb5_enctype enctype
,
110 krb5_principal fast_princ
;
112 hdb_entry
*fast_user
= NULL
;
113 Key
*cookie_key
= NULL
;
114 krb5_crypto fast_crypto
= NULL
;
119 ret
= krb5_make_principal(r
->context
, &fast_princ
,
120 KRB5_WELLKNOWN_ORG_H5L_REALM
,
121 KRB5_WELLKNOWN_NAME
, "org.h5l.fast-cookie", NULL
);
125 ret
= _kdc_db_fetch(r
->context
, r
->config
, fast_princ
,
126 HDB_F_GET_FAST_COOKIE
, NULL
, &fast_db
, &fast_user
);
130 if (enctype
== KRB5_ENCTYPE_NULL
)
131 ret
= _kdc_get_preferred_key(r
->context
, r
->config
, fast_user
,
132 "fast-cookie", &enctype
, &cookie_key
);
134 ret
= hdb_enctype2key(r
->context
, fast_user
, NULL
,
135 enctype
, &cookie_key
);
139 ret
= krb5_crypto_init(r
->context
, &cookie_key
->key
,
140 ENCTYPE_NULL
, &fast_crypto
);
144 ret
= salt_fastuser_crypto(r
, ticket_client
,
145 cookie_key
->key
.keytype
,
146 fast_crypto
, crypto
);
152 _kdc_free_ent(r
->context
, fast_db
, fast_user
);
154 krb5_crypto_destroy(r
->context
, fast_crypto
);
155 krb5_free_principal(r
->context
, fast_princ
);
161 static krb5_error_code
162 fast_parse_cookie(astgs_request_t r
,
163 krb5_const_principal ticket_client
,
166 krb5_crypto crypto
= NULL
;
172 ret
= decode_KDCFastCookie(pa
->padata_value
.data
,
173 pa
->padata_value
.length
,
178 if (len
!= pa
->padata_value
.length
|| strcmp("H5L1", data
.version
) != 0) {
179 free_KDCFastCookie(&data
);
180 return KRB5KDC_ERR_POLICY
;
183 ret
= get_fastuser_crypto(r
, ticket_client
, data
.cookie
.etype
, &crypto
);
187 ret
= krb5_decrypt_EncryptedData(r
->context
, crypto
,
190 krb5_crypto_destroy(r
->context
, crypto
);
194 ret
= decode_KDCFastState(d1
.data
, d1
.length
, &r
->fast
, &len
);
199 if (r
->fast
.expiration
< kdc_time
) {
200 kdc_log(r
->context
, r
->config
, 2, "FAST cookie expired");
201 ret
= KRB5KDC_ERR_POLICY
;
206 free_KDCFastCookie(&data
);
211 static krb5_error_code
212 fast_add_cookie(astgs_request_t r
,
213 krb5_const_principal ticket_client
,
214 METHOD_DATA
*method_data
)
216 krb5_crypto crypto
= NULL
;
222 memset(&shell
, 0, sizeof(shell
));
224 r
->fast
.expiration
= kdc_time
+ FAST_EXPIRATION_TIME
;
226 ASN1_MALLOC_ENCODE(KDCFastState
, data
.data
, data
.length
,
227 &r
->fast
, &size
, ret
);
230 heim_assert(size
== data
.length
, "internal asn.1 encoder error");
232 ret
= get_fastuser_crypto(r
, ticket_client
, KRB5_ENCTYPE_NULL
, &crypto
);
234 kdc_log(r
->context
, r
->config
, 0,
235 "Failed to find FAST principal for cookie encryption: %d", ret
);
239 ret
= krb5_encrypt_EncryptedData(r
->context
, crypto
,
241 data
.data
, data
.length
, 0,
243 krb5_crypto_destroy(r
->context
, crypto
);
247 krb5_data_free(&data
);
249 shell
.version
= "H5L1";
251 ASN1_MALLOC_ENCODE(KDCFastCookie
, data
.data
, data
.length
,
253 free_EncryptedData(&shell
.cookie
);
256 heim_assert(size
== data
.length
, "internal asn.1 encoder error");
258 ret
= krb5_padata_add(r
->context
, method_data
,
259 KRB5_PADATA_FX_COOKIE
,
260 data
.data
, data
.length
);
262 krb5_data_zero(&data
);
265 krb5_data_free(&data
);
270 _kdc_fast_mk_response(krb5_context context
,
271 krb5_crypto armor_crypto
,
272 METHOD_DATA
*pa_data
,
273 krb5_keyblock
*strengthen_key
,
274 KrbFastFinished
*finished
,
278 PA_FX_FAST_REPLY fxfastrep
;
279 KrbFastResponse fastrep
;
284 memset(&fxfastrep
, 0, sizeof(fxfastrep
));
285 memset(&fastrep
, 0, sizeof(fastrep
));
286 krb5_data_zero(data
);
289 fastrep
.padata
.val
= pa_data
->val
;
290 fastrep
.padata
.len
= pa_data
->len
;
292 fastrep
.strengthen_key
= strengthen_key
;
293 fastrep
.finished
= finished
;
294 fastrep
.nonce
= nonce
;
296 ASN1_MALLOC_ENCODE(KrbFastResponse
, buf
.data
, buf
.length
,
297 &fastrep
, &size
, ret
);
300 heim_assert(size
== buf
.length
, "internal asn.1 encoder error");
302 fxfastrep
.element
= choice_PA_FX_FAST_REPLY_armored_data
;
304 ret
= krb5_encrypt_EncryptedData(context
,
310 &fxfastrep
.u
.armored_data
.enc_fast_rep
);
311 krb5_data_free(&buf
);
315 ASN1_MALLOC_ENCODE(PA_FX_FAST_REPLY
, data
->data
, data
->length
,
316 &fxfastrep
, &size
, ret
);
317 free_PA_FX_FAST_REPLY(&fxfastrep
);
320 heim_assert(size
== data
->length
, "internal asn.1 encoder error");
327 _kdc_fast_mk_error(astgs_request_t r
,
328 METHOD_DATA
*error_method
,
329 krb5_crypto armor_crypto
,
330 const KDC_REQ_BODY
*req_body
,
331 krb5_error_code outer_error
,
332 krb5_principal error_client
,
333 krb5_principal error_server
,
334 time_t *csec
, int *cusec
,
335 krb5_data
*error_msg
)
341 krb5_data_zero(&e_data
);
343 heim_assert(r
!= NULL
, "invalid request in _kdc_fast_mk_error");
346 * FX-COOKIE can be used outside of FAST, e.g. SRP or GSS.
348 if (armor_crypto
|| r
->fast
.fast_state
.len
) {
349 kdc_log(r
->context
, r
->config
, 5, "Adding FAST cookie for KRB-ERROR");
350 ret
= fast_add_cookie(r
, error_client
, error_method
);
352 kdc_log(r
->context
, r
->config
, 1,
353 "Failed to add FAST cookie: %d", ret
);
354 free_METHOD_DATA(error_method
);
360 PA_FX_FAST_REPLY fxfastrep
;
361 KrbFastResponse fastrep
;
363 memset(&fxfastrep
, 0, sizeof(fxfastrep
));
364 memset(&fastrep
, 0, sizeof(fastrep
));
366 kdc_log(r
->context
, r
->config
, 5, "Making FAST inner KRB-ERROR");
368 /* first add the KRB-ERROR to the fast errors */
370 ret
= krb5_mk_error(r
->context
,
380 kdc_log(r
->context
, r
->config
, 1,
381 "Failed to make inner KRB-ERROR: %d", ret
);
385 ret
= krb5_padata_add(r
->context
, error_method
,
386 KRB5_PADATA_FX_ERROR
,
387 e_data
.data
, e_data
.length
);
389 kdc_log(r
->context
, r
->config
, 1,
390 "Failed to make add FAST PADATA to inner KRB-ERROR: %d", ret
);
391 krb5_data_free(&e_data
);
395 outer_error
= KRB5_KDC_ERR_MORE_PREAUTH_DATA_REQUIRED
;
397 if (r
->fast
.flags
.requested_hidden_names
) {
404 ret
= _kdc_fast_mk_response(r
->context
, armor_crypto
,
405 error_method
, NULL
, NULL
,
406 req_body
->nonce
, &e_data
);
407 free_METHOD_DATA(error_method
);
409 kdc_log(r
->context
, r
->config
, 1,
410 "Failed to make outer KRB-ERROR: %d", ret
);
414 ret
= krb5_padata_add(r
->context
, error_method
,
416 e_data
.data
, e_data
.length
);
418 kdc_log(r
->context
, r
->config
, 1,
419 "Failed to make add FAST PADATA to outer KRB-ERROR: %d", ret
);
423 kdc_log(r
->context
, r
->config
, 5, "Making non-FAST KRB-ERROR");
425 if (error_method
&& error_method
->len
) {
426 ASN1_MALLOC_ENCODE(METHOD_DATA
, e_data
.data
, e_data
.length
,
427 error_method
, &size
, ret
);
429 kdc_log(r
->context
, r
->config
, 1,
430 "Failed to make encode METHOD-DATA: %d", ret
);
433 heim_assert(size
== e_data
.length
, "internal asn.1 encoder error");
436 ret
= krb5_mk_error(r
->context
,
439 (e_data
.length
? &e_data
: NULL
),
445 krb5_data_free(&e_data
);
448 kdc_log(r
->context
, r
->config
, 1,
449 "Failed to make encode KRB-ERROR: %d", ret
);
454 static krb5_error_code
455 fast_unwrap_request(astgs_request_t r
,
456 krb5_ticket
*tgs_ticket
,
457 krb5_auth_context tgs_ac
)
459 krb5_principal armor_server_principal
= NULL
;
460 char *armor_client_principal_name
= NULL
;
461 char *armor_server_principal_name
= NULL
;
462 PA_FX_FAST_REQUEST fxreq
;
463 krb5_auth_context ac
= NULL
;
464 krb5_ticket
*ticket
= NULL
;
465 krb5_flags ap_req_options
;
466 krb5_keyblock armorkey
;
467 krb5_keyblock explicit_armorkey
;
476 memset(&fxreq
, 0, sizeof(fxreq
));
477 memset(&fastreq
, 0, sizeof(fastreq
));
479 pa
= _kdc_find_padata(&r
->req
, &i
, KRB5_PADATA_FX_FAST
);
481 if (tgs_ac
&& r
->fast_asserted
) {
482 kdc_log(r
->context
, r
->config
, 1,
483 "Client asserted FAST but did not include FX-FAST pa-data");
484 ret
= KRB5KRB_AP_ERR_MODIFIED
;
488 kdc_log(r
->context
, r
->config
, 10, "Not a FAST request");
492 ret
= decode_PA_FX_FAST_REQUEST(pa
->padata_value
.data
,
493 pa
->padata_value
.length
,
497 kdc_log(r
->context
, r
->config
, 4,
498 "Failed to decode PA-FX-FAST-REQUEST: %d", ret
);
502 if (fxreq
.element
!= choice_PA_FX_FAST_REQUEST_armored_data
) {
503 kdc_log(r
->context
, r
->config
, 4,
504 "PA-FX-FAST-REQUEST contains unknown type: %d",
506 ret
= KRB5KDC_ERR_PREAUTH_FAILED
;
511 * If check for armor data or it's not a TGS-REQ with implicit
514 if (fxreq
.u
.armored_data
.armor
== NULL
&& tgs_ac
== NULL
) {
515 kdc_log(r
->context
, r
->config
, 4,
516 "AS-REQ armor missing");
517 ret
= KRB5KDC_ERR_PREAUTH_FAILED
;
521 r
->explicit_armor_present
= fxreq
.u
.armored_data
.armor
!= NULL
&& tgs_ac
!= NULL
;
526 if (fxreq
.u
.armored_data
.armor
!= NULL
) {
527 if (fxreq
.u
.armored_data
.armor
->armor_type
!= 1) {
528 kdc_log(r
->context
, r
->config
, 4,
529 "Incorrect AS-REQ armor type");
530 ret
= KRB5KDC_ERR_PREAUTH_FAILED
;
534 ret
= krb5_decode_ap_req(r
->context
,
535 &fxreq
.u
.armored_data
.armor
->armor_value
,
538 kdc_log(r
->context
, r
->config
, 4, "Failed to decode AP-REQ");
542 /* Save that principal that was in the request */
543 ret
= _krb5_principalname2krb5_principal(r
->context
,
544 &armor_server_principal
,
546 ap_req
.ticket
.realm
);
548 free_AP_REQ(&ap_req
);
552 ret
= _kdc_db_fetch(r
->context
, r
->config
, armor_server_principal
,
553 HDB_F_GET_KRBTGT
| HDB_F_DELAY_NEW_KEYS
,
554 (krb5uint32
*)ap_req
.ticket
.enc_part
.kvno
,
555 &r
->armor_serverdb
, &r
->armor_server
);
556 if(ret
== HDB_ERR_NOT_FOUND_HERE
) {
557 free_AP_REQ(&ap_req
);
558 kdc_log(r
->context
, r
->config
, 5,
559 "Armor key does not have secrets at this KDC, "
563 free_AP_REQ(&ap_req
);
564 ret
= KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN
;
568 ret
= hdb_enctype2key(r
->context
, r
->armor_server
, NULL
,
569 ap_req
.ticket
.enc_part
.etype
,
572 free_AP_REQ(&ap_req
);
576 ret
= krb5_verify_ap_req2(r
->context
, &ac
,
578 armor_server_principal
,
583 KRB5_KU_AP_REQ_AUTH
);
584 free_AP_REQ(&ap_req
);
588 ret
= krb5_unparse_name(r
->context
, armor_server_principal
,
589 &armor_server_principal_name
);
593 /* FIXME krb5_verify_ap_req2() also checks this */
594 ret
= _kdc_verify_flags(r
->context
, r
->config
,
595 &r
->armor_ticket
->ticket
,
596 armor_server_principal_name
);
598 kdc_audit_addreason((kdc_request_t
)r
,
599 "Armor TGT expired or invalid");
602 ticket
= r
->armor_ticket
;
604 heim_assert(tgs_ticket
!= NULL
, "TGS authentication context without ticket");
609 krb5_unparse_name(r
->context
, ticket
->client
, &armor_client_principal_name
);
610 kdc_audit_addkv((kdc_request_t
)r
, 0, "armor_client_name", "%s",
611 armor_client_principal_name
? armor_client_principal_name
: "<unknown>");
613 if (ac
->remote_subkey
== NULL
) {
614 krb5_auth_con_free(r
->context
, ac
);
615 kdc_log(r
->context
, r
->config
, 2,
616 "FAST AP-REQ remote subkey missing");
617 ret
= KRB5KDC_ERR_PREAUTH_FAILED
;
621 r
->fast
.flags
.kdc_verified
=
622 !_kdc_is_anonymous_pkinit(r
->context
, ticket
->client
);
624 ret
= _krb5_fast_armor_key(r
->context
,
628 r
->explicit_armor_present
? NULL
: &r
->armor_crypto
);
632 if (r
->explicit_armor_present
) {
633 ret
= _krb5_fast_explicit_armor_key(r
->context
,
635 tgs_ac
->remote_subkey
,
641 krb5_free_keyblock_contents(r
->context
, &explicit_armorkey
);
644 krb5_free_keyblock_contents(r
->context
, &armorkey
);
646 ret
= krb5_decrypt_EncryptedData(r
->context
, r
->armor_crypto
,
648 &fxreq
.u
.armored_data
.enc_fast_req
,
651 kdc_log(r
->context
, r
->config
, 2,
652 "Failed to decrypt FAST request");
656 ret
= decode_KrbFastReq(data
.data
, data
.length
, &fastreq
, NULL
);
657 krb5_data_free(&data
);
662 * verify req-checksum of the outer body
666 * -- For TGS, contains the checksum performed over the type
667 * -- AP-REQ in the PA-TGS-REQ padata.
670 pa
= _kdc_find_padata(&r
->req
, &i
, KRB5_PADATA_TGS_REQ
);
672 kdc_log(r
->context
, r
->config
, 4,
673 "FAST TGS request missing TGS-REQ padata");
674 ret
= KRB5KRB_ERR_GENERIC
;
678 ret
= _kdc_verify_checksum(r
->context
, r
->armor_crypto
,
679 KRB5_KU_FAST_REQ_CHKSUM
,
681 &fxreq
.u
.armored_data
.req_checksum
);
683 kdc_log(r
->context
, r
->config
, 2,
684 "Bad checksum in FAST TGS request");
689 * -- For AS, contains the checksum performed over the type
690 * -- KDC-REQ-BODY for the req-body field of the KDC-REQ
693 ret
= _kdc_verify_checksum(r
->context
, r
->armor_crypto
,
694 KRB5_KU_FAST_REQ_CHKSUM
,
695 &r
->req
.req_body
._save
,
696 &fxreq
.u
.armored_data
.req_checksum
);
698 kdc_log(r
->context
, r
->config
, 2,
699 "Bad checksum in FAST AS request");
705 * check for unsupported mandatory options
707 if (FastOptions2int(fastreq
.fast_options
) & 0xfffc) {
708 kdc_log(r
->context
, r
->config
, 2,
709 "FAST unsupported mandatory option set");
710 ret
= KRB5_KDC_ERR_UNKNOWN_CRITICAL_FAST_OPTIONS
;
714 r
->fast
.flags
.requested_hidden_names
= fastreq
.fast_options
.hide_client_names
;
716 /* KDC MUST ignore outer pa data preauth-14 - 6.5.5 */
718 free_METHOD_DATA(r
->req
.padata
);
720 ALLOC(r
->req
.padata
);
722 ret
= copy_METHOD_DATA(&fastreq
.padata
, r
->req
.padata
);
726 free_KDC_REQ_BODY(&r
->req
.req_body
);
727 ret
= copy_KDC_REQ_BODY(&fastreq
.req_body
, &r
->req
.req_body
);
731 kdc_log(r
->context
, r
->config
, 5, "Client selected FAST");
734 if (ac
&& ac
!= tgs_ac
)
735 krb5_auth_con_free(r
->context
, ac
);
737 krb5_free_principal(r
->context
, armor_server_principal
);
738 krb5_xfree(armor_client_principal_name
);
739 krb5_xfree(armor_server_principal_name
);
741 free_KrbFastReq(&fastreq
);
742 free_PA_FX_FAST_REQUEST(&fxreq
);
751 _kdc_fast_unwrap_request(astgs_request_t r
,
752 krb5_ticket
*tgs_ticket
,
753 krb5_auth_context tgs_ac
)
759 if (!r
->config
->enable_fast
)
762 ret
= fast_unwrap_request(r
, tgs_ticket
, tgs_ac
);
767 * FX-COOKIE can be used outside of FAST, e.g. SRP or GSS.
769 pa
= _kdc_find_padata(&r
->req
, &i
, KRB5_PADATA_FX_COOKIE
);
771 krb5_const_principal ticket_client
= NULL
;
774 ticket_client
= tgs_ticket
->client
;
776 ret
= fast_parse_cookie(r
, ticket_client
, pa
);
783 * Strengthen reply key by mixing with a random key that is
787 _kdc_fast_strengthen_reply_key(astgs_request_t r
)
789 if (r
->armor_crypto
) {
790 krb5_keyblock new_reply_key
;
793 kdc_log(r
->context
, r
->config
, 5,
794 "FAST strengthen reply key with strengthen-key");
796 heim_assert(r
->reply_key
.keytype
!= KRB5_ENCTYPE_NULL
, "NULL reply key enctype");
798 ret
= krb5_generate_random_keyblock(r
->context
, r
->reply_key
.keytype
,
801 krb5_abortx(r
->context
, "random generator fail");
803 ret
= _krb5_fast_cf2(r
->context
,
804 &r
->strengthen_key
, "strengthenkey",
805 &r
->reply_key
, "replykey",
806 &new_reply_key
, NULL
);
810 krb5_free_keyblock_contents(r
->context
, &r
->reply_key
);
811 r
->reply_key
= new_reply_key
;
818 * Zero and free KDCFastState
821 _kdc_free_fast_state(KDCFastState
*state
)
825 for (i
= 0; i
< state
->fast_state
.len
; i
++) {
826 PA_DATA
*pa
= &state
->fast_state
.val
[i
];
828 if (pa
->padata_value
.data
)
829 memset_s(pa
->padata_value
.data
, 0,
830 pa
->padata_value
.length
, pa
->padata_value
.length
);
832 free_KDCFastState(state
);
836 _kdc_fast_check_armor_pac(astgs_request_t r
)
840 krb5_boolean ad_kdc_issued
= FALSE
;
841 krb5_pac mspac
= NULL
;
842 krb5_principal armor_client_principal
= NULL
;
844 hdb_entry
*armor_client
= NULL
;
845 char *armor_client_principal_name
= NULL
;
847 flags
= HDB_F_FOR_TGS_REQ
;
848 if (_kdc_synthetic_princ_used_p(r
->context
, r
->armor_ticket
))
849 flags
|= HDB_F_SYNTHETIC_OK
;
850 if (r
->req
.req_body
.kdc_options
.canonicalize
)
851 flags
|= HDB_F_CANON
;
853 ret
= _krb5_principalname2krb5_principal(r
->context
,
854 &armor_client_principal
,
855 r
->armor_ticket
->ticket
.cname
,
856 r
->armor_ticket
->ticket
.crealm
);
860 ret
= krb5_unparse_name(r
->context
, armor_client_principal
,
861 &armor_client_principal_name
);
865 ret
= _kdc_db_fetch_client(r
->context
, r
->config
, flags
,
866 armor_client_principal
, armor_client_principal_name
,
867 r
->req
.req_body
.realm
, &armor_db
, &armor_client
);
871 ret
= kdc_check_flags(r
, FALSE
, armor_client
, NULL
);
875 ret
= _kdc_check_pac(r
, armor_client_principal
, NULL
,
876 armor_client
, r
->armor_server
,
877 r
->armor_server
, r
->armor_server
,
878 &r
->armor_key
->key
, &r
->armor_key
->key
,
879 &r
->armor_ticket
->ticket
, &ad_kdc_issued
, &mspac
, NULL
, NULL
);
881 const char *msg
= krb5_get_error_message(r
->context
, ret
);
883 kdc_log(r
->context
, r
->config
, 4,
884 "Verify armor PAC (%s) failed for %s (%s) from %s with %s (%s)",
885 armor_client_principal_name
, r
->cname
, r
->sname
,
886 r
->from
, msg
, mspac
? "Ticket unsigned" : "No PAC");
888 krb5_free_error_message(r
->context
, msg
);
893 if (r
->explicit_armor_present
) {
894 r
->explicit_armor_clientdb
= armor_db
;
897 r
->explicit_armor_client
= armor_client
;
900 r
->explicit_armor_pac
= mspac
;
905 krb5_xfree(armor_client_principal_name
);
907 _kdc_free_ent(r
->context
, armor_db
, armor_client
);
908 krb5_free_principal(r
->context
, armor_client_principal
);
909 krb5_pac_free(r
->context
, mspac
);