Changeset 988 for vendor/current/source4/heimdal/kdc
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/heimdal/kdc
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/heimdal/kdc/default_config.c
r740 r988 52 52 c->kdc_warn_pwexpire = 0; 53 53 c->encode_as_rep_as_tgs_rep = FALSE; 54 c->as_use_strongest_session_key = FALSE; 55 c->preauth_use_strongest_session_key = FALSE; 56 c->tgs_use_strongest_session_key = FALSE; 57 c->use_strongest_server_key = TRUE; 54 58 c->check_ticket_addresses = TRUE; 55 59 c->allow_null_ticket_addresses = TRUE; 56 60 c->allow_anonymous = FALSE; 57 61 c->trpolicy = TRPOLICY_ALWAYS_CHECK; 58 c->enable_v4 = FALSE;59 c->enable_kaserver = FALSE;60 c->enable_524 = FALSE;61 c->enable_v4_cross_realm = FALSE;62 62 c->enable_pkinit = FALSE; 63 63 c->pkinit_princ_in_cert = TRUE; … … 71 71 c->require_preauth, 72 72 "kdc", "require-preauth", NULL); 73 c->enable_v4 =74 krb5_config_get_bool_default(context, NULL,75 c->enable_v4,76 "kdc", "enable-kerberos4", NULL);77 c->enable_v4_cross_realm =78 krb5_config_get_bool_default(context, NULL,79 c->enable_v4_cross_realm,80 "kdc",81 "enable-kerberos4-cross-realm", NULL);82 c->enable_524 =83 krb5_config_get_bool_default(context, NULL,84 c->enable_v4,85 "kdc", "enable-524", NULL);86 73 #ifdef DIGEST 87 74 c->enable_digest = … … 133 120 } 134 121 #endif 122 123 c->as_use_strongest_session_key = 124 krb5_config_get_bool_default(context, NULL, 125 c->as_use_strongest_session_key, 126 "kdc", 127 "as-use-strongest-session-key", NULL); 128 c->preauth_use_strongest_session_key = 129 krb5_config_get_bool_default(context, NULL, 130 c->preauth_use_strongest_session_key, 131 "kdc", 132 "preauth-use-strongest-session-key", NULL); 133 c->tgs_use_strongest_session_key = 134 krb5_config_get_bool_default(context, NULL, 135 c->tgs_use_strongest_session_key, 136 "kdc", 137 "tgs-use-strongest-session-key", NULL); 138 c->use_strongest_server_key = 139 krb5_config_get_bool_default(context, NULL, 140 c->use_strongest_server_key, 141 "kdc", 142 "use-strongest-server-key", NULL); 135 143 136 144 c->check_ticket_addresses = … … 181 189 } 182 190 183 {184 const char *p;185 p = krb5_config_get_string (context, NULL,186 "kdc",187 "v4-realm",188 NULL);189 if(p != NULL) {190 c->v4_realm = strdup(p);191 if (c->v4_realm == NULL)192 krb5_errx(context, 1, "out of memory");193 } else {194 c->v4_realm = NULL;195 }196 }197 198 c->enable_kaserver =199 krb5_config_get_bool_default(context,200 NULL,201 c->enable_kaserver,202 "kdc", "enable-kaserver", NULL);203 204 205 191 c->encode_as_rep_as_tgs_rep = 206 192 krb5_config_get_bool_default(context, NULL, … … 224 210 225 211 226 c->pkinit_kdc_identity = 212 c->pkinit_kdc_identity = 227 213 krb5_config_get_string(context, NULL, 228 214 "kdc", "pkinit_identity", NULL); … … 236 222 krb5_config_get_strings(context, NULL, 237 223 "kdc", "pkinit_revoke", NULL); 238 c->pkinit_kdc_ocsp_file = 224 c->pkinit_kdc_ocsp_file = 239 225 krb5_config_get_string(context, NULL, 240 226 "kdc", "pkinit_kdc_ocsp", NULL); … … 273 259 if (config->pkinit_kdc_identity == NULL) { 274 260 if (config->pkinit_kdc_friendly_name == NULL) 275 config->pkinit_kdc_friendly_name = 261 config->pkinit_kdc_friendly_name = 276 262 strdup("O=System Identity,CN=com.apple.kerberos.kdc"); 277 263 config->pkinit_kdc_identity = strdup("KEYCHAIN:"); … … 285 271 if (config->pkinit_kdc_identity == NULL) 286 272 krb5_errx(context, 1, "pkinit enabled but no identity"); 287 273 288 274 if (config->pkinit_kdc_anchors == NULL) 289 275 krb5_errx(context, 1, "pkinit enabled but no X509 anchors"); … … 299 285 return 0; 300 286 #endif /* PKINIT */ 301 } 287 } -
vendor/current/source4/heimdal/kdc/digest.c
r740 r988 258 258 { 259 259 krb5_principal principal = NULL; 260 const char *p, *r ;260 const char *p, *rr; 261 261 262 262 ret = krb5_ticket_get_server(context, ticket, &principal); … … 281 281 goto out; 282 282 } 283 r = krb5_principal_get_realm(context, principal);284 if (r == NULL) {283 rr = krb5_principal_get_realm(context, principal); 284 if (rr == NULL) { 285 285 krb5_free_principal(context, principal); 286 286 goto out; 287 287 } 288 if (strcmp(p, r ) != 0) {288 if (strcmp(p, rr) != 0) { 289 289 krb5_free_principal(context, principal); 290 290 goto out; … … 357 357 if (ret) 358 358 goto out; 359 359 360 360 ret = decode_DigestReqInner(buf.data, buf.length, &ireq, NULL); 361 361 krb5_data_free(&buf); … … 420 420 r.u.initReply.nonce = s; 421 421 } 422 422 423 423 ret = krb5_store_stringz(sp, r.u.initReply.nonce); 424 424 if (ret) { … … 476 476 if (ret) 477 477 goto out; 478 478 479 479 ASN1_MALLOC_ENCODE(Checksum, buf.data, buf.length, &res, &size, ret); 480 480 free_Checksum(&res); … … 548 548 goto out; 549 549 } 550 550 551 551 ret = krb5_storage_to_data(sp, &buf); 552 552 if (ret) { … … 562 562 goto out; 563 563 } 564 564 565 565 /* 566 566 * CHAP does the checksum of the raw nonce, but do it for all … … 569 569 { 570 570 ssize_t ssize; 571 571 572 572 ssize = hex_decode(ireq.u.digestRequest.serverNonce, 573 573 serverNonce.data, serverNonce.length); … … 598 598 unsigned char *p = serverNonce.data; 599 599 uint32_t t; 600 600 601 601 if (serverNonce.length < 4) { 602 602 ret = EINVAL; … … 617 617 unsigned char md[MD5_DIGEST_LENGTH]; 618 618 char *mdx; 619 char id ;619 char idx; 620 620 621 621 if ((config->digests_allowed & CHAP_MD5) == 0) { … … 630 630 goto out; 631 631 } 632 633 if (hex_decode(*ireq.u.digestRequest.identifier, &id , 1) != 1) {632 633 if (hex_decode(*ireq.u.digestRequest.identifier, &idx, 1) != 1) { 634 634 ret = EINVAL; 635 635 krb5_set_error_message(context, ret, "failed to decode identifier"); 636 636 goto out; 637 637 } 638 638 639 639 ret = get_password_entry(context, config, 640 640 ireq.u.digestRequest.username, … … 646 646 647 647 EVP_DigestInit_ex(ctx, EVP_md5(), NULL); 648 EVP_DigestUpdate(ctx, &id , 1);648 EVP_DigestUpdate(ctx, &idx, 1); 649 649 EVP_DigestUpdate(ctx, password, strlen(password)); 650 650 EVP_DigestUpdate(ctx, serverNonce.data, serverNonce.length); … … 692 692 if (ireq.u.digestRequest.realm == NULL) 693 693 goto out; 694 694 695 695 ret = get_password_entry(context, config, 696 696 ireq.u.digestRequest.username, … … 710 710 EVP_DigestUpdate(ctx, password, strlen(password)); 711 711 EVP_DigestFinal_ex(ctx, md, NULL); 712 712 713 713 EVP_DigestInit_ex(ctx, EVP_md5(), NULL); 714 714 EVP_DigestUpdate(ctx, md, sizeof(md)); … … 732 732 goto failed; 733 733 } 734 734 735 735 EVP_DigestInit_ex(ctx, EVP_md5(), NULL); 736 736 EVP_DigestUpdate(ctx, … … 738 738 EVP_DigestUpdate(ctx, *ireq.u.digestRequest.uri, 739 739 strlen(*ireq.u.digestRequest.uri)); 740 740 741 741 /* conf|int */ 742 742 if (strcmp(ireq.u.digestRequest.digest, "clear") != 0) { … … 744 744 EVP_DigestUpdate(ctx, conf_zeros, sizeof(conf_zeros) - 1); 745 745 } 746 746 747 747 EVP_DigestFinal_ex(ctx, md, NULL); 748 748 … … 805 805 struct ntlm_buf answer; 806 806 Key *key = NULL; 807 EVP_MD_CTX *ct x;807 EVP_MD_CTX *ctp; 808 808 809 809 if ((config->digests_allowed & MS_CHAP_V2) == 0) { … … 817 817 "MS-CHAP-V2 clientNonce missing"); 818 818 goto failed; 819 } 819 } 820 820 if (serverNonce.length != 16) { 821 821 ret = EINVAL; … … 832 832 username++; 833 833 834 ct x= EVP_MD_CTX_create();834 ctp = EVP_MD_CTX_create(); 835 835 836 836 /* ChallangeHash */ 837 EVP_DigestInit_ex(ct x, EVP_sha1(), NULL);837 EVP_DigestInit_ex(ctp, EVP_sha1(), NULL); 838 838 { 839 839 ssize_t ssize; 840 840 krb5_data clientNonce; 841 841 842 842 clientNonce.length = strlen(*ireq.u.digestRequest.clientNonce); 843 843 clientNonce.data = malloc(clientNonce.length); … … 846 846 krb5_set_error_message(context, ret, 847 847 "malloc: out of memory"); 848 EVP_MD_CTX_destroy(ct x);848 EVP_MD_CTX_destroy(ctp); 849 849 goto out; 850 850 } … … 856 856 krb5_set_error_message(context, ret, 857 857 "Failed to decode clientNonce"); 858 EVP_MD_CTX_destroy(ct x);858 EVP_MD_CTX_destroy(ctp); 859 859 goto out; 860 860 } 861 EVP_DigestUpdate(ct x, clientNonce.data, ssize);861 EVP_DigestUpdate(ctp, clientNonce.data, ssize); 862 862 free(clientNonce.data); 863 863 } 864 EVP_DigestUpdate(ct x, serverNonce.data, serverNonce.length);865 EVP_DigestUpdate(ct x, username, strlen(username));866 867 EVP_DigestFinal_ex(ct x, challange, NULL);868 869 EVP_MD_CTX_destroy(ct x);864 EVP_DigestUpdate(ctp, serverNonce.data, serverNonce.length); 865 EVP_DigestUpdate(ctp, username, strlen(username)); 866 867 EVP_DigestFinal_ex(ctp, challange, NULL); 868 869 EVP_MD_CTX_destroy(ctp); 870 870 871 871 /* NtPasswordHash */ … … 873 873 if (ret) 874 874 goto failed; 875 875 876 876 ret = _kdc_db_fetch(context, config, clientprincipal, 877 877 HDB_F_GET_CLIENT, NULL, NULL, &user); … … 901 901 goto failed; 902 902 } 903 903 904 904 hex_encode(answer.data, answer.length, &mdx); 905 905 if (mdx == NULL) { … … 924 924 if (r.u.response.success) { 925 925 unsigned char hashhash[MD4_DIGEST_LENGTH]; 926 EVP_MD_CTX *ctx ;927 928 ctx = EVP_MD_CTX_create();926 EVP_MD_CTX *ctxp; 927 928 ctxp = EVP_MD_CTX_create(); 929 929 930 930 /* hashhash */ 931 931 { 932 EVP_DigestInit_ex(ctx , EVP_md4(), NULL);933 EVP_DigestUpdate(ctx ,932 EVP_DigestInit_ex(ctxp, EVP_md4(), NULL); 933 EVP_DigestUpdate(ctxp, 934 934 key->key.keyvalue.data, 935 935 key->key.keyvalue.length); 936 EVP_DigestFinal_ex(ctx , hashhash, NULL);936 EVP_DigestFinal_ex(ctxp, hashhash, NULL); 937 937 } 938 938 939 939 /* GenerateAuthenticatorResponse */ 940 EVP_DigestInit_ex(ctx , EVP_sha1(), NULL);941 EVP_DigestUpdate(ctx , hashhash, sizeof(hashhash));942 EVP_DigestUpdate(ctx , answer.data, answer.length);943 EVP_DigestUpdate(ctx , ms_chap_v2_magic1,940 EVP_DigestInit_ex(ctxp, EVP_sha1(), NULL); 941 EVP_DigestUpdate(ctxp, hashhash, sizeof(hashhash)); 942 EVP_DigestUpdate(ctxp, answer.data, answer.length); 943 EVP_DigestUpdate(ctxp, ms_chap_v2_magic1, 944 944 sizeof(ms_chap_v2_magic1)); 945 EVP_DigestFinal_ex(ctx , md, NULL);946 947 EVP_DigestInit_ex(ctx , EVP_sha1(), NULL);948 EVP_DigestUpdate(ctx , md, sizeof(md));949 EVP_DigestUpdate(ctx , challange, 8);950 EVP_DigestUpdate(ctx , ms_chap_v2_magic2,945 EVP_DigestFinal_ex(ctxp, md, NULL); 946 947 EVP_DigestInit_ex(ctxp, EVP_sha1(), NULL); 948 EVP_DigestUpdate(ctxp, md, sizeof(md)); 949 EVP_DigestUpdate(ctxp, challange, 8); 950 EVP_DigestUpdate(ctxp, ms_chap_v2_magic2, 951 951 sizeof(ms_chap_v2_magic2)); 952 EVP_DigestFinal_ex(ctx , md, NULL);952 EVP_DigestFinal_ex(ctxp, md, NULL); 953 953 954 954 r.u.response.rsp = calloc(1, sizeof(*r.u.response.rsp)); … … 956 956 free(answer.data); 957 957 krb5_clear_error_message(context); 958 EVP_MD_CTX_destroy(ctx );958 EVP_MD_CTX_destroy(ctxp); 959 959 ret = ENOMEM; 960 960 goto out; … … 965 965 free(answer.data); 966 966 krb5_clear_error_message(context); 967 EVP_MD_CTX_destroy(ctx );967 EVP_MD_CTX_destroy(ctxp); 968 968 ret = ENOMEM; 969 969 goto out; … … 971 971 972 972 /* get_master, rfc 3079 3.4 */ 973 EVP_DigestInit_ex(ctx , EVP_sha1(), NULL);974 EVP_DigestUpdate(ctx , hashhash, 16);975 EVP_DigestUpdate(ctx , answer.data, answer.length);976 EVP_DigestUpdate(ctx , ms_rfc3079_magic1,973 EVP_DigestInit_ex(ctxp, EVP_sha1(), NULL); 974 EVP_DigestUpdate(ctxp, hashhash, 16); 975 EVP_DigestUpdate(ctxp, answer.data, answer.length); 976 EVP_DigestUpdate(ctxp, ms_rfc3079_magic1, 977 977 sizeof(ms_rfc3079_magic1)); 978 EVP_DigestFinal_ex(ctx , md, NULL);978 EVP_DigestFinal_ex(ctxp, md, NULL); 979 979 980 980 free(answer.data); 981 981 982 EVP_MD_CTX_destroy(ctx );982 EVP_MD_CTX_destroy(ctxp); 983 983 984 984 r.u.response.session_key = … … 1102 1102 goto out; 1103 1103 } 1104 1104 1105 1105 ret = krb5_storage_write(sp, r.u.ntlmInitReply.challange.data, 8); 1106 1106 if (ret != 8) { … … 1144 1144 Key *key = NULL; 1145 1145 int version; 1146 1146 1147 1147 r.element = choice_DigestRepInner_ntlmResponse; 1148 1148 r.u.ntlmResponse.success = 0; … … 1188 1188 goto out; 1189 1189 } 1190 1190 1191 1191 ret = krb5_storage_read(sp, challange, sizeof(challange)); 1192 1192 if (ret != sizeof(challange)) { … … 1267 1267 unsigned char sessionhash[MD5_DIGEST_LENGTH]; 1268 1268 EVP_MD_CTX *ctx; 1269 1269 1270 1270 if ((config->digests_allowed & NTLM_V1_SESSION) == 0) { 1271 1271 kdc_log(context, config, 0, "NTLM v1-session not allowed"); … … 1280 1280 goto failed; 1281 1281 } 1282 1282 1283 1283 ctx = EVP_MD_CTX_create(); 1284 1284 … … 1298 1298 } 1299 1299 } 1300 1300 1301 1301 ret = heim_ntlm_calculate_ntlm1(key->key.keyvalue.data, 1302 1302 key->key.keyvalue.length, … … 1306 1306 goto failed; 1307 1307 } 1308 1308 1309 1309 if (ireq.u.ntlmRequest.ntlm.length != answer.length || 1310 1310 memcmp(ireq.u.ntlmRequest.ntlm.data, answer.data, answer.length) != 0) … … 1336 1336 EVP_CIPHER_CTX rc4; 1337 1337 size_t len; 1338 1338 1339 1339 if ((flags & NTLM_NEG_KEYEX) == 0) { 1340 1340 ret = EINVAL; … … 1344 1344 goto failed; 1345 1345 } 1346 1346 1347 1347 len = ireq.u.ntlmRequest.sessionkey->length; 1348 1348 if (len != sizeof(masterkey)){ … … 1353 1353 goto failed; 1354 1354 } 1355 1355 1356 1356 1357 1357 EVP_CIPHER_CTX_init(&rc4); … … 1361 1361 sizeof(masterkey)); 1362 1362 EVP_CIPHER_CTX_cleanup(&rc4); 1363 1363 1364 1364 r.u.ntlmResponse.sessionkey = 1365 1365 malloc(sizeof(*r.u.ntlmResponse.sessionkey)); … … 1369 1369 goto out; 1370 1370 } 1371 1371 1372 1372 ret = krb5_data_copy(r.u.ntlmResponse.sessionkey, 1373 1373 masterkey, sizeof(masterkey)); … … 1416 1416 goto out; 1417 1417 } 1418 1418 1419 1419 kdc_log(context, config, 0, "Digest failed with: %s", s); 1420 1420 -
vendor/current/source4/heimdal/kdc/kdc.h
r740 r988 59 59 60 60 krb5_boolean encode_as_rep_as_tgs_rep; /* bug compatibility */ 61 61 62 krb5_boolean as_use_strongest_session_key; 63 krb5_boolean preauth_use_strongest_session_key; 64 krb5_boolean tgs_use_strongest_session_key; 65 krb5_boolean use_strongest_server_key; 66 62 67 krb5_boolean check_ticket_addresses; 63 68 krb5_boolean allow_null_ticket_addresses; 64 69 krb5_boolean allow_anonymous; 65 70 enum krb5_kdc_trpolicy trpolicy; 66 67 char *v4_realm;68 krb5_boolean enable_v4;69 krb5_boolean enable_v4_cross_realm;70 krb5_boolean enable_v4_per_principal;71 72 krb5_boolean enable_kaserver;73 74 krb5_boolean enable_524;75 71 76 72 krb5_boolean enable_pkinit; -
vendor/current/source4/heimdal/kdc/kerberos5.c
r740 r988 75 75 return NULL; 76 76 77 while( *start < req->padata->len){77 while((size_t)*start < req->padata->len){ 78 78 (*start)++; 79 if(req->padata->val[*start - 1].padata_type == type)79 if(req->padata->val[*start - 1].padata_type == (unsigned)type) 80 80 return &req->padata->val[*start - 1]; 81 81 } … … 124 124 125 125 krb5_error_code 126 _kdc_find_etype(krb5_context context, const hdb_entry_ex *princ, 126 _kdc_find_etype(krb5_context context, krb5_boolean use_strongest_session_key, 127 krb5_boolean is_preauth, hdb_entry_ex *princ, 127 128 krb5_enctype *etypes, unsigned len, 128 Key **ret_key) 129 { 129 krb5_enctype *ret_enctype, Key **ret_key) 130 { 131 krb5_error_code ret; 132 krb5_salt def_salt; 133 krb5_enctype enctype = ETYPE_NULL; 134 Key *key; 130 135 int i; 131 krb5_error_code ret = KRB5KDC_ERR_ETYPE_NOSUPP; 132 krb5_salt def_salt; 133 134 krb5_get_pw_salt (context, princ->entry.principal, &def_salt); 135 136 for(i = 0; ret != 0 && i < len ; i++) { 137 Key *key = NULL; 138 139 if (krb5_enctype_valid(context, etypes[i]) != 0 && 140 !_kdc_is_weak_exception(princ->entry.principal, etypes[i])) 141 continue; 142 143 while (hdb_next_enctype2key(context, &princ->entry, etypes[i], &key) == 0) { 144 if (key->key.keyvalue.length == 0) { 145 ret = KRB5KDC_ERR_NULL_KEY; 136 137 /* We'll want to avoid keys with v4 salted keys in the pre-auth case... */ 138 ret = krb5_get_pw_salt(context, princ->entry.principal, &def_salt); 139 if (ret) 140 return ret; 141 142 ret = KRB5KDC_ERR_ETYPE_NOSUPP; 143 144 if (use_strongest_session_key) { 145 const krb5_enctype *p; 146 krb5_enctype clientbest = ETYPE_NULL; 147 int j; 148 149 /* 150 * Pick the strongest key that the KDC, target service, and 151 * client all support, using the local cryptosystem enctype 152 * list in strongest-to-weakest order to drive the search. 153 * 154 * This is not what RFC4120 says to do, but it encourages 155 * adoption of stronger enctypes. This doesn't play well with 156 * clients that have multiple Kerberos client implementations 157 * available with different supported enctype lists. 158 */ 159 160 /* drive the search with local supported enctypes list */ 161 p = krb5_kerberos_enctypes(context); 162 for (i = 0; p[i] != ETYPE_NULL && enctype == ETYPE_NULL; i++) { 163 if (krb5_enctype_valid(context, p[i]) != 0) 146 164 continue; 165 166 /* check that the client supports it too */ 167 for (j = 0; j < len && enctype == ETYPE_NULL; j++) { 168 if (p[i] != etypes[j]) 169 continue; 170 /* save best of union of { client, crypto system } */ 171 if (clientbest == ETYPE_NULL) 172 clientbest = p[i]; 173 /* check target princ support */ 174 ret = hdb_enctype2key(context, &princ->entry, p[i], &key); 175 if (ret) 176 continue; 177 if (is_preauth && !is_default_salt_p(&def_salt, key)) 178 continue; 179 enctype = p[i]; 147 180 } 148 *ret_key = key; 149 ret = 0; 150 if (is_default_salt_p(&def_salt, key)) { 151 krb5_free_salt (context, def_salt); 152 return ret; 181 } 182 if (clientbest != ETYPE_NULL && enctype == ETYPE_NULL) 183 enctype = clientbest; 184 else if (enctype == ETYPE_NULL) 185 ret = KRB5KDC_ERR_ETYPE_NOSUPP; 186 if (ret == 0 && ret_enctype != NULL) 187 *ret_enctype = enctype; 188 if (ret == 0 && ret_key != NULL) 189 *ret_key = key; 190 } else { 191 /* 192 * Pick the first key from the client's enctype list that is 193 * supported by the cryptosystem and by the given principal. 194 * 195 * RFC4120 says we SHOULD pick the first _strong_ key from the 196 * client's list... not the first key... If the admin disallows 197 * weak enctypes in krb5.conf and selects this key selection 198 * algorithm, then we get exactly what RFC4120 says. 199 */ 200 for(key = NULL, i = 0; ret != 0 && i < len; i++, key = NULL) { 201 202 if (krb5_enctype_valid(context, etypes[i]) != 0 && 203 !_kdc_is_weak_exception(princ->entry.principal, etypes[i])) 204 continue; 205 206 while (hdb_next_enctype2key(context, &princ->entry, etypes[i], &key) == 0) { 207 if (key->key.keyvalue.length == 0) { 208 ret = KRB5KDC_ERR_NULL_KEY; 209 continue; 210 } 211 if (ret_key != NULL) 212 *ret_key = key; 213 if (ret_enctype != NULL) 214 *ret_enctype = etypes[i]; 215 ret = 0; 216 if (is_preauth && is_default_salt_p(&def_salt, key)) 217 goto out; 153 218 } 154 219 } 155 220 } 221 222 out: 156 223 krb5_free_salt (context, def_salt); 157 224 return ret; … … 212 279 struct rk_strpool *p = NULL; 213 280 char *str; 214 int i;215 281 size_t i; 282 216 283 for (i = 0; i < padata->len; i++) { 217 284 switch(padata->val[i].padata_type) { … … 241 308 if (p == NULL) 242 309 p = rk_strpoolprintf(p, "none"); 243 310 244 311 str = rk_strpoolcollect(p); 245 312 kdc_log(context, config, 0, "Client sent patypes: %s", str); … … 265 332 unsigned char *buf; 266 333 size_t buf_size; 267 size_t len ;334 size_t len = 0; 268 335 krb5_error_code ret; 269 336 krb5_crypto crypto; … … 615 682 struct rk_strpool *p; 616 683 char *str; 617 int i;684 size_t i; 618 685 619 686 p = rk_strpoolprintf(NULL, "%s", "Client supported enctypes: "); … … 687 754 kdc_log(context, config, 0, 688 755 "Client (%s) is locked out", client_name); 689 return KRB5KDC_ERR_ POLICY;756 return KRB5KDC_ERR_CLIENT_REVOKED; 690 757 } 691 758 … … 695 762 return KRB5KDC_ERR_POLICY; 696 763 } 697 764 698 765 if(!client->flags.client){ 699 766 kdc_log(context, config, 0, … … 701 768 return KRB5KDC_ERR_POLICY; 702 769 } 703 770 704 771 if (client->valid_start && *client->valid_start > kdc_time) { 705 772 char starttime_str[100]; … … 711 778 return KRB5KDC_ERR_CLIENT_NOTYET; 712 779 } 713 780 714 781 if (client->valid_end && *client->valid_end < kdc_time) { 715 782 char endtime_str[100]; … … 721 788 return KRB5KDC_ERR_NAME_EXP; 722 789 } 723 790 724 791 if (client->pw_end && *client->pw_end < kdc_time 725 792 && (server_ex == NULL || !server_ex->entry.flags.change_pw)) { … … 810 877 krb5_boolean result; 811 878 krb5_boolean only_netbios = TRUE; 812 int i;879 size_t i; 813 880 814 881 if(config->check_ticket_addresses == 0) … … 912 979 Key *ckey, *skey; 913 980 EncryptionKey *reply_key = NULL, session_key; 914 int flags = 0;981 int flags = HDB_F_FOR_AS_REQ; 915 982 #ifdef PKINIT 916 983 pk_client_params *pkp = NULL; … … 977 1044 } 978 1045 } else if (b->kdc_options.request_anonymous) { 979 kdc_log(context, config, 0, 1046 kdc_log(context, config, 0, 980 1047 "Request for a anonymous ticket with non " 981 1048 "anonymous client name: %s", client_name); … … 994 1061 kdc_log(context, config, 5, "client %s does not have secrets at this KDC, need to proxy", client_name); 995 1062 goto out; 1063 } else if (ret == HDB_ERR_WRONG_REALM) { 1064 char *fixed_client_name = NULL; 1065 1066 ret = krb5_unparse_name(context, client->entry.principal, 1067 &fixed_client_name); 1068 if (ret) { 1069 goto out; 1070 } 1071 1072 kdc_log(context, config, 0, "WRONG_REALM - %s -> %s", 1073 client_name, fixed_client_name); 1074 free(fixed_client_name); 1075 1076 ret = krb5_mk_error_ext(context, 1077 KRB5_KDC_ERR_WRONG_REALM, 1078 NULL, /* e_text */ 1079 NULL, /* e_data */ 1080 server_princ, 1081 NULL, /* client_name */ 1082 &client->entry.principal->realm, 1083 NULL, /* client_time */ 1084 NULL, /* client_usec */ 1085 reply); 1086 goto out; 996 1087 } else if(ret){ 997 1088 const char *msg = krb5_get_error_message(context, ret); … … 1019 1110 1020 1111 /* 1021 * Select a session enctype from the list of the crypto system s1022 * supported enctype , is supported by the client and is one of the1023 * enctype of the enctype of the krbtgt.1112 * Select a session enctype from the list of the crypto system 1113 * supported enctypes that is supported by the client and is one of 1114 * the enctype of the enctype of the service (likely krbtgt). 1024 1115 * 1025 * The lat er is used as a hint what enctype all KDC are supporting1026 * to make sure a newer version of KDC won t generate a session1027 * enctype that an dolder version of a KDC in the same realm can't1116 * The latter is used as a hint of what enctypes all KDC support, 1117 * to make sure a newer version of KDC won't generate a session 1118 * enctype that an older version of a KDC in the same realm can't 1028 1119 * decrypt. 1029 * 1030 * But if the KDC admin is paranoid and doesn't want to have "no 1120 */ 1121 ret = _kdc_find_etype(context, config->as_use_strongest_session_key, FALSE, 1122 client, b->etype.val, b->etype.len, &sessionetype, 1123 NULL); 1124 if (ret) { 1125 kdc_log(context, config, 0, 1126 "Client (%s) from %s has no common enctypes with KDC " 1127 "to use for the session key", 1128 client_name, from); 1129 goto out; 1130 } 1131 /* 1132 * But if the KDC admin is paranoid and doesn't want to have "not 1031 1133 * the best" enctypes on the krbtgt, lets save the best pick from 1032 1134 * the client list and hope that that will work for any other 1033 1135 * KDCs. 1034 1136 */ 1035 {1036 const krb5_enctype *p;1037 krb5_enctype clientbest = ETYPE_NULL;1038 int i, j;1039 1040 p = krb5_kerberos_enctypes(context);1041 1042 sessionetype = ETYPE_NULL;1043 1044 for (i = 0; p[i] != ETYPE_NULL && sessionetype == ETYPE_NULL; i++) {1045 if (krb5_enctype_valid(context, p[i]) != 0)1046 continue;1047 1048 for (j = 0; j < b->etype.len && sessionetype == ETYPE_NULL; j++) {1049 Key *dummy;1050 /* check with client */1051 if (p[i] != b->etype.val[j])1052 continue;1053 /* save best of union of { client, crypto system } */1054 if (clientbest == ETYPE_NULL)1055 clientbest = p[i];1056 /* check with krbtgt */1057 ret = hdb_enctype2key(context, &server->entry, p[i], &dummy);1058 if (ret)1059 continue;1060 sessionetype = p[i];1061 }1062 }1063 /* if krbtgt had no shared keys with client, pick clients best */1064 if (clientbest != ETYPE_NULL && sessionetype == ETYPE_NULL) {1065 sessionetype = clientbest;1066 } else if (sessionetype == ETYPE_NULL) {1067 kdc_log(context, config, 0,1068 "Client (%s) from %s has no common enctypes with KDC"1069 "to use for the session key",1070 client_name, from);1071 goto out;1072 }1073 }1074 1137 1075 1138 /* … … 1112 1175 ret = _kdc_pk_check_client(context, 1113 1176 config, 1114 clientdb, 1177 clientdb, 1115 1178 client, 1116 1179 pkp, … … 1120 1183 "impersonate principal"; 1121 1184 _kdc_pk_free_client_param(context, pkp); 1122 1185 1123 1186 kdc_log(context, config, 0, "%s", e_text); 1124 1187 pkp = NULL; … … 1137 1200 ts_enc: 1138 1201 #endif 1202 1203 if (client->entry.flags.locked_out) { 1204 ret = KRB5KDC_ERR_CLIENT_REVOKED; 1205 kdc_log(context, config, 0, 1206 "Client (%s) is locked out", client_name); 1207 goto out; 1208 } 1209 1139 1210 kdc_log(context, config, 5, "Looking for ENC-TS pa-data -- %s", 1140 1211 client_name); … … 1149 1220 Key *pa_key; 1150 1221 char *str; 1151 1222 1152 1223 found_pa = 1; 1153 1224 1154 1225 if (b->kdc_options.request_anonymous) { 1155 1226 ret = KRB5KRB_AP_ERR_BAD_INTEGRITY; … … 1168 1239 goto out; 1169 1240 } 1170 1241 1171 1242 ret = hdb_enctype2key(context, &client->entry, 1172 1243 enc_data.etype, &pa_key); … … 1257 1328 if (abs(kdc_time - p.patimestamp) > context->max_skew) { 1258 1329 char client_time[100]; 1259 1330 1260 1331 krb5_format_time(context, p.patimestamp, 1261 1332 client_time, sizeof(client_time), TRUE); … … 1354 1425 * If there is a client key, send ETYPE_INFO{,2} 1355 1426 */ 1356 ret = _kdc_find_etype(context, client, b->etype.val, b->etype.len, 1357 &ckey); 1427 ret = _kdc_find_etype(context, 1428 config->preauth_use_strongest_session_key, TRUE, 1429 client, b->etype.val, b->etype.len, NULL, &ckey); 1358 1430 if (ret == 0) { 1359 1431 … … 1385 1457 } 1386 1458 } 1387 1459 1388 1460 ASN1_MALLOC_ENCODE(METHOD_DATA, buf, len, &method_data, &len, ret); 1389 1461 free_METHOD_DATA(&method_data); … … 1400 1472 goto out; 1401 1473 } 1402 1403 if (clientdb->hdb_auth_status)1404 (clientdb->hdb_auth_status)(context, clientdb, client,1405 HDB_AUTH_SUCCESS);1406 1474 1407 1475 /* … … 1415 1483 if(ret) 1416 1484 goto out; 1485 1486 if (clientdb->hdb_auth_status) 1487 (clientdb->hdb_auth_status)(context, clientdb, client, 1488 HDB_AUTH_SUCCESS); 1417 1489 1418 1490 /* … … 1504 1576 time_t start; 1505 1577 time_t t; 1506 1578 1507 1579 start = et.authtime = kdc_time; 1508 1580 … … 1659 1731 goto out; 1660 1732 1661 /* Add signing of alias referral */1662 if (f.canonicalize) {1663 PA_ClientCanonicalized canon;1664 krb5_data data;1665 PA_DATA pa;1666 krb5_crypto crypto;1667 size_t len;1668 1669 memset(&canon, 0, sizeof(canon));1670 1671 canon.names.requested_name = *b->cname;1672 canon.names.mapped_name = client->entry.principal->name;1673 1674 ASN1_MALLOC_ENCODE(PA_ClientCanonicalizedNames, data.data, data.length,1675 &canon.names, &len, ret);1676 if (ret)1677 goto out;1678 if (data.length != len)1679 krb5_abortx(context, "internal asn.1 error");1680 1681 /* sign using "returned session key" */1682 ret = krb5_crypto_init(context, &et.key, 0, &crypto);1683 if (ret) {1684 free(data.data);1685 goto out;1686 }1687 1688 ret = krb5_create_checksum(context, crypto,1689 KRB5_KU_CANONICALIZED_NAMES, 0,1690 data.data, data.length,1691 &canon.canon_checksum);1692 free(data.data);1693 krb5_crypto_destroy(context, crypto);1694 if (ret)1695 goto out;1696 1697 ASN1_MALLOC_ENCODE(PA_ClientCanonicalized, data.data, data.length,1698 &canon, &len, ret);1699 free_Checksum(&canon.canon_checksum);1700 if (ret)1701 goto out;1702 if (data.length != len)1703 krb5_abortx(context, "internal asn.1 error");1704 1705 pa.padata_type = KRB5_PADATA_CLIENT_CANONICALIZED;1706 pa.padata_value = data;1707 ret = add_METHOD_DATA(rep.padata, &pa);1708 free(data.data);1709 if (ret)1710 goto out;1711 }1712 1713 1733 if (rep.padata->len == 0) { 1714 1734 free(rep.padata); … … 1784 1804 out: 1785 1805 free_AS_REP(&rep); 1786 if(ret != 0 && ret != HDB_ERR_NOT_FOUND_HERE ){1806 if(ret != 0 && ret != HDB_ERR_NOT_FOUND_HERE && reply->length == 0) { 1787 1807 krb5_mk_error(context, 1788 1808 ret, … … 1827 1847 { 1828 1848 krb5_error_code ret; 1829 size_t size ;1849 size_t size = 0; 1830 1850 1831 1851 if (tkt->authorization_data == NULL) { … … 1836 1856 } 1837 1857 } 1838 1858 1839 1859 /* add the entry to the last element */ 1840 1860 { … … 1864 1884 if (ade.ad_data.length != size) 1865 1885 krb5_abortx(context, "internal asn.1 encoder error"); 1866 1886 1867 1887 ret = add_AuthorizationData(tkt->authorization_data, &ade); 1868 1888 der_free_octet_string(&ade.ad_data); -
vendor/current/source4/heimdal/kdc/krb5tgs.c
r740 r988 65 65 krb5_error_code ret; 66 66 int pos; 67 67 68 68 if (ad == NULL || ad->len == 0) 69 69 return KRB5KDC_ERR_PADATA_TYPE_NOSUPP; … … 114 114 krb5_data data; 115 115 krb5_crypto crypto = NULL; 116 size_t size ;116 size_t size = 0; 117 117 118 118 if (server && principals) { … … 124 124 { 125 125 KRB5SignedPathData spd; 126 126 127 127 spd.client = client; 128 128 spd.authtime = tkt->authtime; 129 129 spd.delegated = principals; 130 130 spd.method_data = NULL; 131 131 132 132 ASN1_MALLOC_ENCODE(KRB5SignedPathData, data.data, data.length, 133 133 &spd, &size, ret); … … 204 204 KRB5SignedPathData spd; 205 205 KRB5SignedPath sp; 206 size_t size ;206 size_t size = 0; 207 207 208 208 ret = decode_KRB5SignedPath(data.data, data.length, &sp, NULL); … … 280 280 krb5_kdc_configuration *config, 281 281 const krb5_principal client_principal, 282 const krb5_principal delegated_proxy_principal, 282 283 hdb_entry_ex *client, 283 284 hdb_entry_ex *server, 284 285 hdb_entry_ex *krbtgt, 285 const EncryptionKey *server_ key,286 const EncryptionKey * krbtgt_check_key,286 const EncryptionKey *server_check_key, 287 const EncryptionKey *server_sign_key, 287 288 const EncryptionKey *krbtgt_sign_key, 288 289 EncTicketPart *tkt, … … 329 330 ret = krb5_pac_verify(context, pac, tkt->authtime, 330 331 client_principal, 331 krbtgt_check_key, NULL);332 server_check_key, NULL); 332 333 if (ret) { 333 334 krb5_pac_free(context, pac); … … 336 337 337 338 ret = _kdc_pac_verify(context, client_principal, 339 delegated_proxy_principal, 338 340 client, server, krbtgt, &pac, &signed_pac); 339 341 if (ret) { … … 352 354 ret = _krb5_pac_sign(context, pac, tkt->authtime, 353 355 client_principal, 354 server_ key, krbtgt_sign_key, rspac);356 server_sign_key, krbtgt_sign_key, rspac); 355 357 } 356 358 krb5_pac_free(context, pac); 357 359 358 360 return ret; 359 361 } … … 374 376 { 375 377 KDCOptions f = b->kdc_options; 376 378 377 379 if(f.validate){ 378 380 if(!tgt->flags.invalid || tgt->starttime == NULL){ … … 413 415 if(tgt->flags.forwarded) 414 416 et->flags.forwarded = 1; 415 417 416 418 if(f.proxiable){ 417 419 if(!tgt->flags.proxiable){ … … 483 485 if (et->renew_till != NULL) 484 486 et->endtime = min(*et->renew_till, et->endtime); 485 } 487 } 486 488 487 489 #if 0 … … 505 507 HDB *clientdb, 506 508 hdb_entry_ex *client, 507 krb5_const_principal server) 509 hdb_entry_ex *server, 510 krb5_const_principal target) 508 511 { 509 512 const HDB_Ext_Constrained_delegation_acl *acl; 510 513 krb5_error_code ret; 511 int i; 512 513 /* if client delegates to itself, that ok */ 514 if (krb5_principal_compare(context, client->entry.principal, server) == TRUE) 515 return 0; 514 size_t i; 515 516 /* 517 * constrained_delegation (S4U2Proxy) only works within 518 * the same realm. We use the already canonicalized version 519 * of the principals here, while "target" is the principal 520 * provided by the client. 521 */ 522 if(!krb5_realm_compare(context, client->entry.principal, server->entry.principal)) { 523 ret = KRB5KDC_ERR_BADOPTION; 524 kdc_log(context, config, 0, 525 "Bad request for constrained delegation"); 526 return ret; 527 } 516 528 517 529 if (clientdb->hdb_check_constrained_delegation) { 518 ret = clientdb->hdb_check_constrained_delegation(context, clientdb, client, server);530 ret = clientdb->hdb_check_constrained_delegation(context, clientdb, client, target); 519 531 if (ret == 0) 520 532 return 0; 521 533 } else { 534 /* if client delegates to itself, that ok */ 535 if (krb5_principal_compare(context, client->entry.principal, server->entry.principal) == TRUE) 536 return 0; 537 522 538 ret = hdb_entry_get_ConstrainedDelegACL(&client->entry, &acl); 523 539 if (ret) { … … 525 541 return ret; 526 542 } 527 543 528 544 if (acl) { 529 545 for (i = 0; i < acl->len; i++) { 530 if (krb5_principal_compare(context, server, &acl->val[i]) == TRUE)546 if (krb5_principal_compare(context, target, &acl->val[i]) == TRUE) 531 547 return 0; 532 548 } … … 607 623 char **realms, **tmp; 608 624 unsigned int num_realms; 609 int i;625 size_t i; 610 626 611 627 switch (tr->tr_type) { … … 827 843 *et.renew_till = et.authtime + renew; 828 844 } 829 845 830 846 if(et.renew_till){ 831 847 *et.renew_till = min(*et.renew_till, *tgt->renew_till); … … 861 877 goto out; 862 878 } 863 879 864 880 if (auth_data) { 865 881 unsigned int i = 0; … … 901 917 if (ret) 902 918 goto out; 903 et.crealm = tgt ->crealm;919 et.crealm = tgt_name->realm; 904 920 et.cname = tgt_name->name; 905 921 906 922 ek.key = et.key; 907 923 /* MIT must have at least one last_req */ … … 1005 1021 { 1006 1022 krb5_authenticator auth; 1007 size_t len ;1023 size_t len = 0; 1008 1024 unsigned char *buf; 1009 1025 size_t buf_size; … … 1032 1048 goto out; 1033 1049 } 1034 1050 1035 1051 /* XXX should not re-encode this */ 1036 1052 ASN1_MALLOC_ENCODE(KDC_REQ_BODY, buf, buf_size, b, &len, ret); … … 1091 1107 return new_realm; 1092 1108 } 1093 1109 1094 1110 1095 1111 static krb5_boolean … … 1105 1121 if (server->name.name_string.len == 1) 1106 1122 name = server->name.name_string.val[0]; 1107 else if (server->name.name_string.len > 1) 1123 else if (server->name.name_string.len == 3) { 1124 /* 1125 This is used to give referrals for the 1126 E3514235-4B06-11D1-AB04-00C04FC2DCD2/NTDSGUID/DNSDOMAIN 1127 SPN form, which is used for inter-domain communication in AD 1128 */ 1129 name = server->name.name_string.val[2]; 1130 kdc_log(context, config, 0, "Giving 3 part referral for %s", name); 1131 *realms = malloc(sizeof(char *)*2); 1132 if (*realms == NULL) { 1133 krb5_set_error_message(context, ENOMEM, N_("malloc: out of memory", "")); 1134 return FALSE; 1135 } 1136 (*realms)[0] = strdup(name); 1137 (*realms)[1] = NULL; 1138 return TRUE; 1139 } else if (server->name.name_string.len > 1) 1108 1140 name = server->name.name_string.val[1]; 1109 1141 else … … 1132 1164 int *rk_is_subkey) 1133 1165 { 1166 static char failed[] = "<unparse_name failed>"; 1134 1167 krb5_ap_req ap_req; 1135 1168 krb5_error_code ret; … … 1175 1208 ret = krb5_unparse_name(context, princ, &p); 1176 1209 if (ret != 0) 1177 p = "<unparse_name failed>";1210 p = failed; 1178 1211 krb5_free_principal(context, princ); 1179 1212 kdc_log(context, config, 5, "Ticket-granting ticket account %s does not have secrets at this KDC, need to proxy", p); … … 1187 1220 ret = krb5_unparse_name(context, princ, &p); 1188 1221 if (ret != 0) 1189 p = "<unparse_name failed>";1222 p = failed; 1190 1223 krb5_free_principal(context, princ); 1191 1224 kdc_log(context, config, 0, … … 1205 1238 krb5_free_principal(context, princ); 1206 1239 if (ret != 0) 1207 p = "<unparse_name failed>";1240 p = failed; 1208 1241 kdc_log(context, config, 0, 1209 1242 "Ticket kvno = %d, DB kvno = %d (%s)", … … 1250 1283 ticket, 1251 1284 KRB5_KU_TGS_REQ_AUTH); 1252 1285 1253 1286 krb5_free_principal(context, princ); 1254 1287 if(ret) { … … 1380 1413 const PrincipalName *requested_principal, 1381 1414 krb5_data *outdata) 1382 { 1415 { 1383 1416 PA_ServerReferralData ref; 1384 1417 krb5_error_code ret; 1385 1418 EncryptedData ed; 1386 1419 krb5_data data; 1387 size_t size ;1420 size_t size = 0; 1388 1421 1389 1422 memset(&ref, 0, sizeof(ref)); … … 1465 1498 { 1466 1499 krb5_error_code ret; 1467 krb5_principal cp = NULL, sp = NULL; 1468 krb5_principal client_principal = NULL; 1500 krb5_principal cp = NULL, sp = NULL, tp = NULL, dp = NULL; 1469 1501 krb5_principal krbtgt_principal = NULL; 1470 char *spn = NULL, *cpn = NULL ;1502 char *spn = NULL, *cpn = NULL, *tpn = NULL, *dpn = NULL; 1471 1503 hdb_entry_ex *server = NULL, *client = NULL, *s4u2self_impersonated_client = NULL; 1472 1504 HDB *clientdb, *s4u2self_impersonated_clientdb; … … 1492 1524 Key *tkey_check; 1493 1525 Key *tkey_sign; 1526 int flags = HDB_F_FOR_TGS_REQ; 1494 1527 1495 1528 memset(&sessionkey, 0, sizeof(sessionkey)); … … 1500 1533 s = b->sname; 1501 1534 r = b->realm; 1535 1536 if (b->kdc_options.canonicalize) 1537 flags |= HDB_F_CANON; 1502 1538 1503 1539 if(b->kdc_options.enc_tkt_in_skey){ … … 1506 1542 krb5_principal p; 1507 1543 Key *uukey; 1508 1544 1509 1545 if(b->additional_tickets == NULL || 1510 1546 b->additional_tickets->len == 0){ … … 1552 1588 1553 1589 _krb5_principalname2krb5_principal(context, &sp, *s, r); 1554 ret = krb5_unparse_name(context, sp, &spn); 1590 ret = krb5_unparse_name(context, sp, &spn); 1555 1591 if (ret) 1556 1592 goto out; … … 1575 1611 1576 1612 server_lookup: 1577 ret = _kdc_db_fetch(context, config, sp, HDB_F_GET_SERVER | HDB_F_CANON,1613 ret = _kdc_db_fetch(context, config, sp, HDB_F_GET_SERVER | flags, 1578 1614 NULL, NULL, &server); 1579 1615 … … 1581 1617 kdc_log(context, config, 5, "target %s does not have secrets at this KDC, need to proxy", sp); 1582 1618 goto out; 1619 } else if (ret == HDB_ERR_WRONG_REALM) { 1620 if (ref_realm) 1621 free(ref_realm); 1622 ref_realm = strdup(server->entry.principal->realm); 1623 if (ref_realm == NULL) { 1624 ret = ENOMEM; 1625 goto out; 1626 } 1627 1628 kdc_log(context, config, 5, 1629 "Returning a referral to realm %s for " 1630 "server %s.", 1631 ref_realm, spn); 1632 krb5_free_principal(context, sp); 1633 sp = NULL; 1634 free(spn); 1635 spn = NULL; 1636 ret = krb5_make_principal(context, &sp, r, KRB5_TGS_NAME, 1637 ref_realm, NULL); 1638 if (ret) 1639 goto out; 1640 ret = krb5_unparse_name(context, sp, &spn); 1641 if (ret) 1642 goto out; 1643 1644 goto server_lookup; 1583 1645 } else if(ret){ 1584 1646 const char *new_rlm, *msg; … … 1597 1659 krb5_make_principal(context, &sp, r, 1598 1660 KRB5_TGS_NAME, new_rlm, NULL); 1599 ret = krb5_unparse_name(context, sp, &spn); 1661 ret = krb5_unparse_name(context, sp, &spn); 1600 1662 if (ret) 1601 1663 goto out; … … 1647 1709 1648 1710 if(b->kdc_options.enc_tkt_in_skey) { 1649 int i;1711 size_t i; 1650 1712 ekey = &adtkt.key; 1651 1713 for(i = 0; i < b->etype.len; i++) … … 1663 1725 } else { 1664 1726 Key *skey; 1665 1666 ret = _kdc_find_etype(context, server, 1667 b->etype.val, b->etype.len, &skey); 1727 1728 ret = _kdc_find_etype(context, 1729 config->tgs_use_strongest_session_key, FALSE, 1730 server, b->etype.val, b->etype.len, NULL, 1731 &skey); 1668 1732 if(ret) { 1669 1733 kdc_log(context, config, 0, … … 1675 1739 kvno = server->entry.kvno; 1676 1740 } 1677 1741 1678 1742 ret = krb5_generate_random_keyblock(context, etype, &sessionkey); 1679 1743 if (ret) … … 1702 1766 * sign check may have been on an old kvno, and the server may 1703 1767 * have been an incoming trust) */ 1704 ret = krb5_make_principal(context, &krbtgt_principal, 1768 ret = krb5_make_principal(context, &krbtgt_principal, 1705 1769 krb5_principal_get_comp_string(context, 1706 1770 krbtgt->entry.principal, 1707 1771 1), 1708 KRB5_TGS_NAME, 1772 KRB5_TGS_NAME, 1709 1773 krb5_principal_get_comp_string(context, 1710 1774 krbtgt->entry.principal, … … 1720 1784 if (ret) { 1721 1785 krb5_error_code ret2; 1722 char * tpn, *tpn2;1723 ret = krb5_unparse_name(context, krbtgt->entry.principal, & tpn);1724 ret2 = krb5_unparse_name(context, krbtgt ->entry.principal, &tpn2);1786 char *ktpn, *ktpn2; 1787 ret = krb5_unparse_name(context, krbtgt->entry.principal, &ktpn); 1788 ret2 = krb5_unparse_name(context, krbtgt_principal, &ktpn2); 1725 1789 kdc_log(context, config, 0, 1726 1790 "Request with wrong krbtgt: %s, %s not found in our database", 1727 (ret == 0) ? tpn : "<unknown>", (ret2 == 0) ?tpn2 : "<unknown>");1791 (ret == 0) ? ktpn : "<unknown>", (ret2 == 0) ? ktpn2 : "<unknown>"); 1728 1792 if(ret == 0) 1729 free( tpn);1793 free(ktpn); 1730 1794 if(ret2 == 0) 1731 free( tpn2);1795 free(ktpn2); 1732 1796 ret = KRB5KRB_AP_ERR_NOT_US; 1733 1797 goto out; … … 1741 1805 if (strcmp(krb5_principal_get_realm(context, server->entry.principal), 1742 1806 krb5_principal_get_realm(context, krbtgt_out->entry.principal)) != 0) { 1743 char * tpn;1744 ret = krb5_unparse_name(context, krbtgt_out->entry.principal, & tpn);1807 char *ktpn; 1808 ret = krb5_unparse_name(context, krbtgt_out->entry.principal, &ktpn); 1745 1809 kdc_log(context, config, 0, 1746 1810 "Request with wrong krbtgt: %s", 1747 (ret == 0) ? tpn : "<unknown>");1811 (ret == 0) ? ktpn : "<unknown>"); 1748 1812 if(ret == 0) 1749 free( tpn);1813 free(ktpn); 1750 1814 ret = KRB5KRB_AP_ERR_NOT_US; 1751 1815 } … … 1759 1823 } 1760 1824 1761 ret = _kdc_db_fetch(context, config, cp, HDB_F_GET_CLIENT | HDB_F_CANON,1825 ret = _kdc_db_fetch(context, config, cp, HDB_F_GET_CLIENT | flags, 1762 1826 NULL, &clientdb, &client); 1763 1827 if(ret == HDB_ERR_NOT_FOUND_HERE) { … … 1789 1853 } 1790 1854 1791 ret = check_PAC(context, config, cp, 1792 client, server, krbtgt, ekey, &tkey_check->key, &tkey_sign->key, 1855 ret = check_PAC(context, config, cp, NULL, 1856 client, server, krbtgt, 1857 &tkey_check->key, 1858 ekey, &tkey_sign->key, 1793 1859 tgt, &rspac, &signedpath); 1794 1860 if (ret) { … … 1822 1888 */ 1823 1889 1824 client_principal = cp; 1890 /* by default the tgt principal matches the client principal */ 1891 tp = cp; 1892 tpn = cpn; 1825 1893 1826 1894 if (client) { … … 1833 1901 krb5_data datack; 1834 1902 PA_S4U2Self self; 1835 char *selfcpn = NULL;1836 1903 const char *str; 1837 1904 … … 1876 1943 1877 1944 ret = _krb5_principalname2krb5_principal(context, 1878 & client_principal,1945 &tp, 1879 1946 self.name, 1880 1947 self.realm); … … 1883 1950 goto out; 1884 1951 1885 ret = krb5_unparse_name(context, client_principal, &selfcpn);1952 ret = krb5_unparse_name(context, tp, &tpn); 1886 1953 if (ret) 1887 1954 goto out; … … 1891 1958 krb5_pac p = NULL; 1892 1959 krb5_data_free(&rspac); 1893 ret = _kdc_db_fetch(context, config, client_principal, HDB_F_GET_CLIENT | HDB_F_CANON,1960 ret = _kdc_db_fetch(context, config, tp, HDB_F_GET_CLIENT | flags, 1894 1961 NULL, &s4u2self_impersonated_clientdb, &s4u2self_impersonated_client); 1895 1962 if (ret) { … … 1905 1972 ret = KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN; 1906 1973 msg = krb5_get_error_message(context, ret); 1907 kdc_log(context, config, 1, "S2U4Self principal to impersonate %s not found in database: %s", cpn, msg); 1974 kdc_log(context, config, 1, 1975 "S2U4Self principal to impersonate %s not found in database: %s", 1976 tpn, msg); 1908 1977 krb5_free_error_message(context, msg); 1909 1978 goto out; … … 1912 1981 if (ret) { 1913 1982 kdc_log(context, config, 0, "PAC generation failed for -- %s", 1914 selfcpn);1983 tpn); 1915 1984 goto out; 1916 1985 } … … 1923 1992 if (ret) { 1924 1993 kdc_log(context, config, 0, "PAC signing failed for -- %s", 1925 selfcpn);1994 tpn); 1926 1995 goto out; 1927 1996 } … … 1938 2007 "to impersonate to service " 1939 2008 "(tried for user %s to service %s)", 1940 cpn, selfcpn, spn); 1941 free(selfcpn); 2009 cpn, tpn, spn); 1942 2010 goto out; 1943 2011 } … … 1955 2023 } 1956 2024 kdc_log(context, config, 0, "s4u2self %s impersonating %s to " 1957 "service %s %s", cpn, selfcpn, spn, str); 1958 free(selfcpn); 2025 "service %s %s", cpn, tpn, spn, str); 1959 2026 } 1960 2027 } … … 1972 2039 Key *clientkey; 1973 2040 Ticket *t; 1974 char *str;1975 2041 1976 2042 /* … … 2003 2069 } 2004 2070 2071 ret = _krb5_principalname2krb5_principal(context, 2072 &tp, 2073 adtkt.cname, 2074 adtkt.crealm); 2075 if (ret) 2076 goto out; 2077 2078 ret = krb5_unparse_name(context, tp, &tpn); 2079 if (ret) 2080 goto out; 2081 2082 ret = _krb5_principalname2krb5_principal(context, 2083 &dp, 2084 t->sname, 2085 t->realm); 2086 if (ret) 2087 goto out; 2088 2089 ret = krb5_unparse_name(context, dp, &dpn); 2090 if (ret) 2091 goto out; 2092 2005 2093 /* check that ticket is valid */ 2006 2094 if (adtkt.flags.forwardable == 0) { 2007 2095 kdc_log(context, config, 0, 2008 2096 "Missing forwardable flag on ticket for " 2009 "constrained delegation from %s to %s ", cpn, spn); 2097 "constrained delegation from %s (%s) as %s to %s ", 2098 cpn, dpn, tpn, spn); 2010 2099 ret = KRB5KDC_ERR_BADOPTION; 2011 2100 goto out; 2012 2101 } 2013 2102 2014 ret = check_constrained_delegation(context, config, clientdb, 2015 client, s p);2103 ret = check_constrained_delegation(context, config, clientdb, 2104 client, server, sp); 2016 2105 if (ret) { 2017 2106 kdc_log(context, config, 0, 2018 "constrained delegation from %s to %s not allowed", 2019 cpn, spn); 2020 goto out; 2021 } 2022 2023 ret = _krb5_principalname2krb5_principal(context, 2024 &client_principal, 2025 adtkt.cname, 2026 adtkt.crealm); 2027 if (ret) 2028 goto out; 2029 2030 ret = krb5_unparse_name(context, client_principal, &str); 2031 if (ret) 2032 goto out; 2033 2034 ret = verify_flags(context, config, &adtkt, str); 2107 "constrained delegation from %s (%s) as %s to %s not allowed", 2108 cpn, dpn, tpn, spn); 2109 goto out; 2110 } 2111 2112 ret = verify_flags(context, config, &adtkt, tpn); 2035 2113 if (ret) { 2036 free(str); 2114 goto out; 2115 } 2116 2117 krb5_data_free(&rspac); 2118 2119 /* 2120 * generate the PAC for the user. 2121 * 2122 * TODO: pass in t->sname and t->realm and build 2123 * a S4U_DELEGATION_INFO blob to the PAC. 2124 */ 2125 ret = check_PAC(context, config, tp, dp, 2126 client, server, krbtgt, 2127 &clientkey->key, 2128 ekey, &tkey_sign->key, 2129 &adtkt, &rspac, &ad_signedpath); 2130 if (ret) { 2131 const char *msg = krb5_get_error_message(context, ret); 2132 kdc_log(context, config, 0, 2133 "Verify delegated PAC failed to %s for client" 2134 "%s (%s) as %s from %s with %s", 2135 spn, cpn, dpn, tpn, from, msg); 2136 krb5_free_error_message(context, msg); 2037 2137 goto out; 2038 2138 } … … 2048 2148 NULL, 2049 2149 &ad_signedpath); 2050 if (ret == 0 && !ad_signedpath)2051 ret = KRB5KDC_ERR_BADOPTION;2052 2150 if (ret) { 2053 2151 const char *msg = krb5_get_error_message(context, ret); 2054 2152 kdc_log(context, config, 0, 2055 2153 "KRB5SignedPath check from service %s failed " 2056 "for delegation to %s for client %s "2154 "for delegation to %s for client %s (%s)" 2057 2155 "from %s failed with %s", 2058 spn, str, cpn, from, msg);2156 spn, tpn, dpn, cpn, from, msg); 2059 2157 krb5_free_error_message(context, msg); 2060 free(str); 2158 goto out; 2159 } 2160 2161 if (!ad_signedpath) { 2162 ret = KRB5KDC_ERR_BADOPTION; 2163 kdc_log(context, config, 0, 2164 "Ticket not signed with PAC nor SignedPath service %s failed " 2165 "for delegation to %s for client %s (%s)" 2166 "from %s", 2167 spn, tpn, dpn, cpn, from); 2061 2168 goto out; 2062 2169 } 2063 2170 2064 2171 kdc_log(context, config, 0, "constrained delegation for %s " 2065 "from %s to %s", str, cpn, spn); 2066 free(str); 2172 "from %s (%s) to %s", tpn, cpn, dpn, spn); 2067 2173 } 2068 2174 … … 2093 2199 goto out; 2094 2200 } 2095 2201 2096 2202 /* 2097 2203 * If this is an referral, add server referral data to the … … 2135 2241 config, 2136 2242 b, 2137 client_principal,2243 tp, 2138 2244 tgt, 2139 2245 replykey, … … 2155 2261 e_text, 2156 2262 reply); 2157 2263 2158 2264 out: 2265 if (tpn != cpn) 2266 free(tpn); 2159 2267 free(spn); 2160 2268 free(cpn); 2161 2269 if (dpn) 2270 free(dpn); 2271 2162 2272 krb5_data_free(&rspac); 2163 2273 krb5_free_keyblock_contents(context, &sessionkey); … … 2171 2281 _kdc_free_ent(context, s4u2self_impersonated_client); 2172 2282 2173 if ( client_principal && client_principal!= cp)2174 krb5_free_principal(context, client_principal);2283 if (tp && tp != cp) 2284 krb5_free_principal(context, tp); 2175 2285 if (cp) 2176 2286 krb5_free_principal(context, cp); 2287 if (dp) 2288 krb5_free_principal(context, dp); 2177 2289 if (sp) 2178 2290 krb5_free_principal(context, sp); … … 2225 2337 if(tgs_req == NULL){ 2226 2338 ret = KRB5KDC_ERR_PADATA_TYPE_NOSUPP; 2227 2339 2228 2340 kdc_log(context, config, 0, 2229 2341 "TGS-REQ from %s without PA-TGS-REQ", from); -
vendor/current/source4/heimdal/kdc/kx509.c
r740 r988 260 260 if (ret) 261 261 goto out; 262 262 263 263 return 0; 264 264 out: … … 356 356 goto out; 357 357 } 358 358 359 359 ret = KRB5KDC_ERR_SERVER_NOMATCH; 360 360 krb5_set_error_message(context, ret, -
vendor/current/source4/heimdal/kdc/log.c
r740 r988 51 51 krb5_config_free_strings(s); 52 52 }else { 53 char *s; 54 asprintf(&s, "0-1/FILE:%s/%s", hdb_db_dir(context), KDC_LOG_FILE); 55 krb5_addlog_dest(context, config->logf, s); 56 free(s); 53 char *ss; 54 if (asprintf(&ss, "0-1/FILE:%s/%s", hdb_db_dir(context), 55 KDC_LOG_FILE) < 0) 56 err(1, NULL); 57 krb5_addlog_dest(context, config->logf, ss); 58 free(ss); 57 59 } 58 60 krb5_set_warn_dest(context, config->logf); -
vendor/current/source4/heimdal/kdc/misc.c
r740 r988 41 41 krb5_const_principal principal, 42 42 unsigned flags, 43 krb5 int32 *kvno_ptr,43 krb5uint32 *kvno_ptr, 44 44 HDB **db, 45 45 hdb_entry_ex **h) … … 49 49 int i; 50 50 unsigned kvno = 0; 51 krb5_principal enterprise_principal = NULL; 52 krb5_const_principal princ; 53 54 *h = NULL; 51 55 52 56 if (kvno_ptr) { … … 55 59 } 56 60 57 ent = calloc (1, sizeof (*ent)); 58 if (ent == NULL) { 59 krb5_set_error_message(context, ENOMEM, "malloc: out of memory"); 60 return ENOMEM; 61 ent = calloc(1, sizeof (*ent)); 62 if (ent == NULL) 63 return krb5_enomem(context); 64 65 if (principal->name.name_type == KRB5_NT_ENTERPRISE_PRINCIPAL) { 66 if (principal->name.name_string.len != 1) { 67 ret = KRB5_PARSE_MALFORMED; 68 krb5_set_error_message(context, ret, 69 "malformed request: " 70 "enterprise name with %d name components", 71 principal->name.name_string.len); 72 goto out; 73 } 74 ret = krb5_parse_name(context, principal->name.name_string.val[0], 75 &enterprise_principal); 76 if (ret) 77 goto out; 61 78 } 62 79 63 for(i = 0; i < config->num_db; i++) { 64 krb5_principal enterprise_principal = NULL; 65 if (!(config->db[i]->hdb_capability_flags & HDB_CAP_F_HANDLE_ENTERPRISE_PRINCIPAL) 66 && principal->name.name_type == KRB5_NT_ENTERPRISE_PRINCIPAL) { 67 if (principal->name.name_string.len != 1) { 68 ret = KRB5_PARSE_MALFORMED; 69 krb5_set_error_message(context, ret, 70 "malformed request: " 71 "enterprise name with %d name components", 72 principal->name.name_string.len); 73 free(ent); 74 return ret; 75 } 76 ret = krb5_parse_name(context, principal->name.name_string.val[0], 77 &enterprise_principal); 78 if (ret) { 79 free(ent); 80 return ret; 81 } 82 83 principal = enterprise_principal; 84 } 85 80 for (i = 0; i < config->num_db; i++) { 86 81 ret = config->db[i]->hdb_open(context, config->db[i], O_RDONLY, 0); 87 82 if (ret) { … … 92 87 } 93 88 89 princ = principal; 90 if (!(config->db[i]->hdb_capability_flags & HDB_CAP_F_HANDLE_ENTERPRISE_PRINCIPAL) && enterprise_principal) 91 princ = enterprise_principal; 92 94 93 ret = config->db[i]->hdb_fetch_kvno(context, 95 94 config->db[i], 96 princ ipal,95 princ, 97 96 flags | HDB_F_DECRYPT, 98 97 kvno, 99 98 ent); 99 config->db[i]->hdb_close(context, config->db[i]); 100 100 101 krb5_free_principal(context, enterprise_principal); 102 103 config->db[i]->hdb_close(context, config->db[i]); 104 if(ret == 0) { 101 switch (ret) { 102 case HDB_ERR_WRONG_REALM: 103 /* 104 * the ent->entry.principal just contains hints for the client 105 * to retry. This is important for enterprise principal routing 106 * between trusts. 107 */ 108 /* fall through */ 109 case 0: 105 110 if (db) 106 111 *db = config->db[i]; 107 112 *h = ent; 108 return 0; 113 ent = NULL; 114 goto out; 115 116 case HDB_ERR_NOENTRY: 117 /* Check the other databases */ 118 continue; 119 120 default: 121 /* 122 * This is really important, because errors like 123 * HDB_ERR_NOT_FOUND_HERE (used to indicate to Samba that 124 * the RODC on which this code is running does not have 125 * the key we need, and so a proxy to the KDC is required) 126 * have specific meaning, and need to be propogated up. 127 */ 128 goto out; 109 129 } 110 130 } 131 132 if (ret == HDB_ERR_NOENTRY) { 133 krb5_set_error_message(context, ret, "no such entry found in hdb"); 134 } 135 out: 136 krb5_free_principal(context, enterprise_principal); 111 137 free(ent); 112 krb5_set_error_message(context, ret,113 "no such entry found in hdb");114 138 return ret; 115 139 } … … 135 159 Key **key) 136 160 { 137 const krb5_enctype *p;138 161 krb5_error_code ret; 139 162 int i; 140 163 141 p = krb5_kerberos_enctypes(context); 164 if (config->use_strongest_server_key) { 165 const krb5_enctype *p = krb5_kerberos_enctypes(context); 142 166 143 for (i = 0; p[i] != ETYPE_NULL; i++) { 144 if (krb5_enctype_valid(context, p[i]) != 0) 145 continue; 146 ret = hdb_enctype2key(context, &h->entry, p[i], key); 147 if (ret == 0) { 148 *enctype = p[i]; 167 for (i = 0; p[i] != ETYPE_NULL; i++) { 168 if (krb5_enctype_valid(context, p[i]) != 0) 169 continue; 170 ret = hdb_enctype2key(context, &h->entry, p[i], key); 171 if (ret != 0) 172 continue; 173 if (enctype != NULL) 174 *enctype = p[i]; 175 return 0; 176 } 177 } else { 178 *key = NULL; 179 180 for (i = 0; i < h->entry.keys.len; i++) { 181 if (krb5_enctype_valid(context, h->entry.keys.val[i].key.keytype) 182 != 0) 183 continue; 184 ret = hdb_enctype2key(context, &h->entry, 185 h->entry.keys.val[i].key.keytype, key); 186 if (ret != 0) 187 continue; 188 if (enctype != NULL) 189 *enctype = (*key)->key.keytype; 149 190 return 0; 150 191 } … … 153 194 krb5_set_error_message(context, EINVAL, 154 195 "No valid kerberos key found for %s", name); 155 return EINVAL; 196 return EINVAL; /* XXX */ 156 197 } 157 198 -
vendor/current/source4/heimdal/kdc/pkinit.c
r740 r988 117 117 size_t buf_size; 118 118 krb5_error_code ret; 119 size_t len ;119 size_t len = 0; 120 120 krb5_timestamp now; 121 121 Checksum checksum; … … 149 149 return ret; 150 150 } 151 151 152 152 if (a->paChecksum == NULL) { 153 153 krb5_clear_error_message(context); … … 223 223 if (!DH_generate_key(client_params->u.dh.key)) { 224 224 ret = KRB5KRB_ERR_GENERIC; 225 krb5_set_error_message(context, ret, 225 krb5_set_error_message(context, ret, 226 226 "Can't generate Diffie-Hellman keys"); 227 227 goto out; … … 238 238 239 239 dh_gen_keylen = DH_compute_key(dh_gen_key,client_params->u.dh.public_key, client_params->u.dh.key); 240 if (dh_gen_keylen == -1) {240 if (dh_gen_keylen == (size_t)-1) { 241 241 ret = KRB5KRB_ERR_GENERIC; 242 242 krb5_set_error_message(context, ret, … … 282 282 } 283 283 284 dh_gen_keylen = ECDH_compute_key(dh_gen_key, size, 284 dh_gen_keylen = ECDH_compute_key(dh_gen_key, size, 285 285 EC_KEY_get0_public_key(client_params->u.ecdh.public_key), 286 286 client_params->u.ecdh.key, NULL); … … 289 289 } else { 290 290 ret = KRB5KRB_ERR_GENERIC; 291 krb5_set_error_message(context, ret, 291 krb5_set_error_message(context, ret, 292 292 "Diffie-Hellman not selected keys"); 293 293 goto out; … … 526 526 } 527 527 528 ret = hx509_certs_merge(context->hx509ctx, trust_anchors, 528 ret = hx509_certs_merge(context->hx509ctx, trust_anchors, 529 529 kdc_identity->anchors); 530 530 if (ret) { … … 539 539 hx509_cert cert; 540 540 unsigned int i; 541 541 542 542 for (i = 0; i < pc->len; i++) { 543 543 ret = hx509_cert_init_data(context->hx509ctx, … … 573 573 if (req->req_body.kdc_options.request_anonymous) { 574 574 ret = KRB5_KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED; 575 krb5_set_error_message(context, ret, 575 krb5_set_error_message(context, ret, 576 576 "Anon not supported in RSA mode"); 577 577 goto out; … … 587 587 goto out; 588 588 } 589 589 590 590 ret = hx509_cms_unwrap_ContentInfo(&r.signed_auth_pack, 591 591 &contentInfoOid, … … 613 613 goto out; 614 614 } 615 615 616 616 /* XXX look at r.kdcPkId */ 617 617 if (r.trustedCertifiers) { … … 625 625 if (ret) { 626 626 krb5_set_error_message(context, ret, 627 "Can't allocate client anchors: %d", 627 "Can't allocate client anchors: %d", 628 628 ret); 629 629 goto out; 630 630 631 631 } 632 /* 632 /* 633 633 * If the client sent more then 10 EDI, don't bother 634 634 * looking more then 10 of performance reasons. … … 652 652 goto out; 653 653 } 654 654 655 655 ret = decode_IssuerAndSerialNumber(edi->val[i].issuerAndSerialNumber->data, 656 656 edi->val[i].issuerAndSerialNumber->length, … … 705 705 goto out; 706 706 } 707 707 708 708 if (!have_data) { 709 709 ret = KRB5KRB_ERR_GENERIC; … … 806 806 free_AuthPack(&ap); 807 807 ret = KRB5_KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED; 808 krb5_set_error_message(context, ret, 808 krb5_set_error_message(context, ret, 809 809 "Anon not supported in RSA mode"); 810 810 goto out; … … 850 850 goto out; 851 851 } 852 852 853 853 if (ap.supportedCMSTypes) { 854 854 ret = hx509_peer_info_set_cms_algs(context->hx509ctx, … … 886 886 if (ret) { 887 887 _kdc_pk_free_client_param(context, cp); 888 } else 888 } else 889 889 *ret_params = cp; 890 890 return ret; … … 922 922 krb5_error_code ret; 923 923 krb5_data buf, signed_data; 924 size_t size ;924 size_t size = 0; 925 925 int do_win2k = 0; 926 926 … … 955 955 default: 956 956 krb5_abortx(context, "internal pkinit error"); 957 } 957 } 958 958 959 959 if (do_win2k) { … … 967 967 } 968 968 kp.nonce = cp->nonce; 969 969 970 970 ASN1_MALLOC_ENCODE(ReplyKeyPack_Win2k, 971 971 buf.data, buf.length, … … 996 996 goto out; 997 997 } 998 998 999 999 ret = krb5_crypto_destroy(context, ascrypto); 1000 1000 if (ret) { … … 1016 1016 hx509_query *q; 1017 1017 hx509_cert cert; 1018 1018 1019 1019 ret = hx509_query_alloc(context->hx509ctx, &q); 1020 1020 if (ret) 1021 1021 goto out; 1022 1022 1023 1023 hx509_query_match_option(q, HX509_QUERY_OPTION_PRIVATE_KEY); 1024 1024 if (config->pkinit_kdc_friendly_name) 1025 1025 hx509_query_match_friendly_name(q, config->pkinit_kdc_friendly_name); 1026 1026 1027 1027 ret = hx509_certs_find(context->hx509ctx, 1028 1028 kdc_identity->certs, … … 1032 1032 if (ret) 1033 1033 goto out; 1034 1034 1035 1035 ret = hx509_cms_create_signed_1(context->hx509ctx, 1036 1036 0, … … 1079 1079 *kdc_cert = NULL; 1080 1080 } 1081 1081 1082 1082 krb5_data_free(&buf); 1083 1083 krb5_data_free(&signed_data); … … 1102 1102 hx509_cert cert; 1103 1103 hx509_query *q; 1104 size_t size ;1104 size_t size = 0; 1105 1105 1106 1106 memset(&contentinfo, 0, sizeof(contentinfo)); … … 1118 1118 if (ret) 1119 1119 return ret; 1120 1120 1121 1121 ASN1_MALLOC_ENCODE(DHPublicKey, buf.data, buf.length, &i, &size, ret); 1122 1122 der_free_heim_integer(&i); … … 1128 1128 if (buf.length != size) 1129 1129 krb5_abortx(context, "Internal ASN.1 encoder error"); 1130 1130 1131 1131 dh_info.subjectPublicKey.length = buf.length * 8; 1132 1132 dh_info.subjectPublicKey.data = buf.data; … … 1155 1155 krb5_abortx(context, "no keyex selected ?"); 1156 1156 1157 1157 1158 1158 dh_info.nonce = cp->nonce; 1159 1159 … … 1176 1176 if (ret) 1177 1177 goto out; 1178 1178 1179 1179 hx509_query_match_option(q, HX509_QUERY_OPTION_PRIVATE_KEY); 1180 1180 if (config->pkinit_kdc_friendly_name) 1181 1181 hx509_query_match_friendly_name(q, config->pkinit_kdc_friendly_name); 1182 1182 1183 1183 ret = hx509_certs_find(context->hx509ctx, 1184 1184 kdc_identity->certs, … … 1188 1188 if (ret) 1189 1189 goto out; 1190 1190 1191 1191 ret = hx509_cms_create_signed_1(context->hx509ctx, 1192 1192 0, … … 1243 1243 { 1244 1244 krb5_error_code ret; 1245 void *buf ;1246 size_t len , size;1245 void *buf = NULL; 1246 size_t len = 0, size = 0; 1247 1247 krb5_enctype enctype; 1248 1248 int pa_type; 1249 1249 hx509_cert kdc_cert = NULL; 1250 int i;1250 size_t i; 1251 1251 1252 1252 if (!config->enable_pkinit) { … … 1264 1264 "No valid enctype available from client"); 1265 1265 goto out; 1266 } 1266 } 1267 1267 enctype = req->req_body.etype.val[i]; 1268 1268 } else … … 1315 1315 krb5_abortx(context, "Internal ASN.1 encoder error"); 1316 1316 1317 ret = krb5_generate_random_keyblock(context, sessionetype, 1317 ret = krb5_generate_random_keyblock(context, sessionetype, 1318 1318 sessionkey); 1319 1319 if (ret) { … … 1369 1369 1370 1370 /* XXX KRB-FX-CF2 */ 1371 ret = krb5_generate_random_keyblock(context, sessionetype, 1371 ret = krb5_generate_random_keyblock(context, sessionetype, 1372 1372 sessionkey); 1373 1373 if (ret) { … … 1421 1421 1422 1422 pa_type = KRB5_PADATA_PK_AS_REP_19; 1423 rep.element = choice_PA_PK_AS_REP_ encKeyPack;1423 rep.element = choice_PA_PK_AS_REP_Win2k_encKeyPack; 1424 1424 1425 1425 ret = krb5_generate_random_keyblock(context, enctype, … … 1464 1464 krb5_abortx(context, "Internal ASN.1 encoder error"); 1465 1465 1466 ret = krb5_generate_random_keyblock(context, sessionetype, 1466 ret = krb5_generate_random_keyblock(context, sessionetype, 1467 1467 sessionkey); 1468 1468 if (ret) { … … 1508 1508 goto out_ocsp; 1509 1509 } 1510 1510 1511 1511 ret = krb5_data_alloc(&ocsp.data, sb.st_size); 1512 1512 if (ret) { … … 1576 1576 { 1577 1577 hx509_octet_string_list list; 1578 int ret, i, found = 0; 1578 int ret, found = 0; 1579 size_t i; 1579 1580 1580 1581 memset(&list, 0 , sizeof(list)); … … 1680 1681 ret = clientdb->hdb_check_pkinit_ms_upn_match(context, clientdb, client, principal); 1681 1682 } else { 1682 1683 1683 1684 /* 1684 1685 * This is very wrong, but will do for a fallback 1685 1686 */ 1686 1687 strupr(principal->realm); 1687 1688 1688 1689 if (krb5_principal_compare(context, principal, client->entry.principal) == FALSE) 1689 1690 ret = KRB5_KDC_ERR_CLIENT_NAME_MISMATCH; … … 1710 1711 krb5_error_code ret; 1711 1712 hx509_name name; 1712 int i;1713 size_t i; 1713 1714 1714 1715 if (cp->cert == NULL) { … … 1738 1739 if (ret == 0 && pc) { 1739 1740 hx509_cert cert; 1740 unsigned int i;1741 1742 for ( i = 0; i < pc->len; i++) {1741 size_t j; 1742 1743 for (j = 0; j < pc->len; j++) { 1743 1744 ret = hx509_cert_init_data(context->hx509ctx, 1744 pc->val[ i].cert.data,1745 pc->val[ i].cert.length,1745 pc->val[j].cert.data, 1746 pc->val[j].cert.length, 1746 1747 &cert); 1747 1748 if (ret) … … 1771 1772 context->hx509ctx, 1772 1773 cp->cert, 1773 clientdb, 1774 clientdb, 1774 1775 client); 1775 1776 if (ret == 0) { … … 1872 1873 krb5_error_code ret; 1873 1874 krb5_data data; 1874 size_t size ;1875 size_t size = 0; 1875 1876 1876 1877 memset(&cas, 0, sizeof(cas)); … … 1938 1939 fclose(f); 1939 1940 } 1940 1941 1941 1942 /* 1942 1943 * … … 1983 1984 hx509_query *q; 1984 1985 hx509_cert cert; 1985 1986 1986 1987 ret = hx509_query_alloc(context->hx509ctx, &q); 1987 1988 if (ret) { … … 1989 1990 return ENOMEM; 1990 1991 } 1991 1992 1992 1993 hx509_query_match_option(q, HX509_QUERY_OPTION_PRIVATE_KEY); 1993 1994 if (config->pkinit_kdc_friendly_name) 1994 1995 hx509_query_match_friendly_name(q, config->pkinit_kdc_friendly_name); 1995 1996 1996 1997 ret = hx509_certs_find(context->hx509ctx, 1997 1998 kdc_identity->certs, -
vendor/current/source4/heimdal/kdc/process.c
r740 r988 48 48 } 49 49 50 static krb5_error_code 50 static krb5_error_code 51 51 kdc_as_req(krb5_context context, 52 52 krb5_kdc_configuration *config, … … 75 75 76 76 77 static krb5_error_code 77 static krb5_error_code 78 78 kdc_tgs_req(krb5_context context, 79 79 krb5_kdc_configuration *config, … … 92 92 if (ret) 93 93 return ret; 94 94 95 95 *claim = 1; 96 96 97 ret = _kdc_tgs_rep(context, config, &req, reply, 97 ret = _kdc_tgs_rep(context, config, &req, reply, 98 98 from, addr, datagram_reply); 99 99 free_TGS_REQ(&req); … … 103 103 #ifdef DIGEST 104 104 105 static krb5_error_code 105 static krb5_error_code 106 106 kdc_digest(krb5_context context, 107 107 krb5_kdc_configuration *config, … … 133 133 #ifdef KX509 134 134 135 static krb5_error_code 135 static krb5_error_code 136 136 kdc_kx509(krb5_context context, 137 137 krb5_kdc_configuration *config, … … 194 194 krb5_data req_buffer; 195 195 int claim = 0; 196 196 197 197 req_buffer.data = buf; 198 198 req_buffer.length = len; … … 233 233 krb5_data req_buffer; 234 234 int claim = 0; 235 235 236 236 req_buffer.data = buf; 237 237 req_buffer.length = len; … … 246 246 return ret; 247 247 } 248 248 249 249 return -1; 250 250 } -
vendor/current/source4/heimdal/kdc/windc.c
r740 r988 56 56 if (windcft->minor_version < KRB5_WINDC_PLUGIN_MINOR) 57 57 continue; 58 58 59 59 (*windcft->init)(context, &windcctx); 60 60 break; … … 85 85 _kdc_pac_verify(krb5_context context, 86 86 const krb5_principal client_principal, 87 const krb5_principal delegated_proxy_principal, 87 88 hdb_entry_ex *client, 88 89 hdb_entry_ex *server, … … 97 98 98 99 ret = windcft->pac_verify(windcctx, context, 99 client_principal, client, server, krbtgt, pac); 100 client_principal, 101 delegated_proxy_principal, 102 client, server, krbtgt, pac); 100 103 if (ret == 0) 101 104 *verified = 1; … … 117 120 req->msg_type == krb_as_req); 118 121 119 return (windcft->client_access)(windcctx, 120 context, config, 121 client_ex, client_name, 122 server_ex, server_name, 122 return (windcft->client_access)(windcctx, 123 context, config, 124 client_ex, client_name, 125 server_ex, server_name, 123 126 req, e_data); 124 127 } -
vendor/current/source4/heimdal/kdc/windc_plugin.h
r740 r988 58 58 typedef krb5_error_code 59 59 (*krb5plugin_windc_pac_verify)(void *, krb5_context, 60 const krb5_principal, 61 struct hdb_entry_ex *, 62 struct hdb_entry_ex *, 63 struct hdb_entry_ex *, 60 const krb5_principal, /* new ticket client */ 61 const krb5_principal, /* delegation proxy */ 62 struct hdb_entry_ex *,/* client */ 63 struct hdb_entry_ex *,/* server */ 64 struct hdb_entry_ex *,/* krbtgt */ 64 65 krb5_pac *); 65 66 66 67 typedef krb5_error_code 67 68 (*krb5plugin_windc_client_access)( 68 void *, krb5_context, 69 void *, krb5_context, 69 70 krb5_kdc_configuration *config, 70 hdb_entry_ex *, const char *, 71 hdb_entry_ex *, const char *, 71 hdb_entry_ex *, const char *, 72 hdb_entry_ex *, const char *, 72 73 KDC_REQ *, krb5_data *); 73 74 74 75 75 #define KRB5_WINDC_PLUGIN G_MINOR 476 #define KRB5_WINDC_PLUGIN _MINOR 476 #define KRB5_WINDC_PLUGIN_MINOR 6 77 #define KRB5_WINDC_PLUGING_MINOR KRB5_WINDC_PLUGIN_MINOR 77 78 78 79 typedef struct krb5plugin_windc_ftable {
Note:
See TracChangeset
for help on using the changeset viewer.