Blame SOURCES/krb5-1.11.2-keycheck.patch

5af5b2
From c7047421487c0e616b881c0922937bc759114233 Mon Sep 17 00:00:00 2001
5af5b2
From: Nathaniel McCallum <npmccallum@redhat.com>
5af5b2
Date: Fri, 3 May 2013 15:44:44 -0400
5af5b2
Subject: [PATCH 1/3] Check for keys in encrypted timestamp/challenge
5af5b2
5af5b2
Encrypted timestamp and encrypted challenge cannot succeed if the
5af5b2
client has no long-term key matching the request enctypes, so do not
5af5b2
offer them in that case.
5af5b2
5af5b2
ticket: 7630
5af5b2
5af5b2
NPM - This is a backport from the upstream fix. See upstream commits:
5af5b2
  https://github.com/krb5/krb5/commit/e50482720a805ecd8c160e4a8f4a846e6327dca2
5af5b2
  https://github.com/krb5/krb5/commit/9593d1311fa5e6e841c429653ad35a63d17c2fdd
5af5b2
---
5af5b2
 src/kdc/kdc_preauth_ec.c    | 23 +++++++++++++++++++++--
5af5b2
 src/kdc/kdc_preauth_encts.c | 22 ++++++++++++++++++++--
5af5b2
 2 files changed, 41 insertions(+), 4 deletions(-)
5af5b2
5af5b2
diff --git a/src/kdc/kdc_preauth_ec.c b/src/kdc/kdc_preauth_ec.c
5af5b2
index 9d7236c..db3ad07 100644
5af5b2
--- a/src/kdc/kdc_preauth_ec.c
5af5b2
+++ b/src/kdc/kdc_preauth_ec.c
5af5b2
@@ -39,8 +39,27 @@ ec_edata(krb5_context context, krb5_kdc_req *request,
5af5b2
          krb5_kdcpreauth_moddata moddata, krb5_preauthtype pa_type,
5af5b2
          krb5_kdcpreauth_edata_respond_fn respond, void *arg)
5af5b2
 {
5af5b2
-    krb5_keyblock *armor_key = cb->fast_armor(context, rock);
5af5b2
-    (*respond)(arg, (armor_key == NULL) ? ENOENT : 0, NULL);
5af5b2
+    krb5_boolean have_client_keys = FALSE;
5af5b2
+    krb5_keyblock *armor_key;
5af5b2
+    krb5_key_data *kd;
5af5b2
+    int i;
5af5b2
+
5af5b2
+    armor_key = cb->fast_armor(context, rock);
5af5b2
+
5af5b2
+    for (i = 0; i < rock->request->nktypes; i++) {
5af5b2
+        if (krb5_dbe_find_enctype(context, rock->client,
5af5b2
+                                  rock->request->ktype[i],
5af5b2
+                                  -1, 0, &kd) == 0) {
5af5b2
+            have_client_keys = TRUE;
5af5b2
+            break;
5af5b2
+        }
5af5b2
+    }
5af5b2
+
5af5b2
+    /* Encrypted challenge only works with FAST, and requires a client key. */
5af5b2
+    if (armor_key == NULL || !have_client_keys)
5af5b2
+        (*respond)(arg, ENOENT, NULL);
5af5b2
+    else
5af5b2
+        (*respond)(arg, 0, NULL);
5af5b2
 }
5af5b2
 
5af5b2
 static void
5af5b2
diff --git a/src/kdc/kdc_preauth_encts.c b/src/kdc/kdc_preauth_encts.c
5af5b2
index d708061..adde6e2 100644
5af5b2
--- a/src/kdc/kdc_preauth_encts.c
5af5b2
+++ b/src/kdc/kdc_preauth_encts.c
5af5b2
@@ -34,9 +34,27 @@ enc_ts_get(krb5_context context, krb5_kdc_req *request,
5af5b2
            krb5_kdcpreauth_moddata moddata, krb5_preauthtype pa_type,
5af5b2
            krb5_kdcpreauth_edata_respond_fn respond, void *arg)
5af5b2
 {
5af5b2
-    krb5_keyblock *armor_key = cb->fast_armor(context, rock);
5af5b2
+    krb5_boolean have_client_keys = FALSE;
5af5b2
+    krb5_keyblock *armor_key;
5af5b2
+    krb5_key_data *kd;
5af5b2
+    int i;
5af5b2
+
5af5b2
+    armor_key = cb->fast_armor(context, rock);
5af5b2
+
5af5b2
+    for (i = 0; i < rock->request->nktypes; i++) {
5af5b2
+        if (krb5_dbe_find_enctype(context, rock->client,
5af5b2
+                                  rock->request->ktype[i],
5af5b2
+                                  -1, 0, &kd) == 0) {
5af5b2
+            have_client_keys = TRUE;
5af5b2
+            break;
5af5b2
+        }
5af5b2
+    }
5af5b2
 
5af5b2
-    (*respond)(arg, (armor_key != NULL) ? ENOENT : 0, NULL);
5af5b2
+    /* Encrypted timestamp must not be used with FAST, and requires a key. */
5af5b2
+    if (armor_key != NULL || !have_client_keys)
5af5b2
+        (*respond)(arg, ENOENT, NULL);
5af5b2
+    else
5af5b2
+        (*respond)(arg, 0, NULL);
5af5b2
 }
5af5b2
 
5af5b2
 static void
5af5b2
-- 
5af5b2
1.8.2.1
5af5b2
5af5b2
5af5b2
From 4d19790527e2c9d52bb05abd6048a63a1a8c222c Mon Sep 17 00:00:00 2001
5af5b2
From: Greg Hudson <ghudson@mit.edu>
5af5b2
Date: Mon, 29 Apr 2013 14:55:31 -0400
5af5b2
Subject: [PATCH 2/3] Don't send empty etype info from KDC
5af5b2
5af5b2
RFC 4120 prohibits empty ETYPE-INFO2 sequences (though not ETYPE-INFO
5af5b2
sequences), and our client errors out if it sees an empty sequence of
5af5b2
either.
5af5b2
5af5b2
ticket: 7630
5af5b2
---
5af5b2
 src/kdc/kdc_preauth.c | 5 +++++
5af5b2
 1 file changed, 5 insertions(+)
5af5b2
5af5b2
diff --git a/src/kdc/kdc_preauth.c b/src/kdc/kdc_preauth.c
5af5b2
index 42a37a8..5c3b615 100644
5af5b2
--- a/src/kdc/kdc_preauth.c
5af5b2
+++ b/src/kdc/kdc_preauth.c
5af5b2
@@ -1404,6 +1404,11 @@ etype_info_helper(krb5_context context, krb5_kdc_req *request,
5af5b2
             seen_des++;
5af5b2
         }
5af5b2
     }
5af5b2
+
5af5b2
+    /* If the list is empty, don't send it at all. */
5af5b2
+    if (i == 0)
5af5b2
+        goto cleanup;
5af5b2
+
5af5b2
     if (etype_info2)
5af5b2
         retval = encode_krb5_etype_info2(entry, &scratch);
5af5b2
     else
5af5b2
-- 
5af5b2
1.8.2.1
5af5b2
5af5b2
5af5b2
From a04cf2e89f4101eb6c2ec44ef1948976fe5fe9d3 Mon Sep 17 00:00:00 2001
5af5b2
From: Greg Hudson <ghudson@mit.edu>
5af5b2
Date: Thu, 2 May 2013 16:15:32 -0400
5af5b2
Subject: [PATCH 3/3] Make AS requests work with no client key
5af5b2
5af5b2
If we cannot find a client key while preparing an AS reply, give
5af5b2
preauth mechanisms a chance to replace the reply key before erroring
5af5b2
out.
5af5b2
5af5b2
ticket: 7630
5af5b2
---
5af5b2
 src/kdc/do_as_req.c   | 36 ++++++++++++++++++++----------------
5af5b2
 src/kdc/kdc_preauth.c |  6 ++++++
5af5b2
 2 files changed, 26 insertions(+), 16 deletions(-)
5af5b2
5af5b2
diff --git a/src/kdc/do_as_req.c b/src/kdc/do_as_req.c
5af5b2
index 79da300..cb91803 100644
5af5b2
--- a/src/kdc/do_as_req.c
5af5b2
+++ b/src/kdc/do_as_req.c
5af5b2
@@ -195,23 +195,18 @@ finish_process_as_req(struct as_req_state *state, krb5_error_code errcode)
5af5b2
                                    useenctype, -1, 0, &client_key))
5af5b2
             break;
5af5b2
     }
5af5b2
-    if (!(client_key)) {
5af5b2
-        /* Cannot find an appropriate key */
5af5b2
-        state->status = "CANT_FIND_CLIENT_KEY";
5af5b2
-        errcode = KRB5KDC_ERR_ETYPE_NOSUPP;
5af5b2
-        goto egress;
5af5b2
-    }
5af5b2
-    state->rock.client_key = client_key;
5af5b2
 
5af5b2
-    /* convert client.key_data into a real key */
5af5b2
-    if ((errcode = krb5_dbe_decrypt_key_data(kdc_context, NULL,
5af5b2
-                                             client_key,
5af5b2
-                                             &state->client_keyblock,
5af5b2
-                                             NULL))) {
5af5b2
-        state->status = "DECRYPT_CLIENT_KEY";
5af5b2
-        goto egress;
5af5b2
+    if (client_key != NULL) {
5af5b2
+        /* Decrypt the client key data entry to get the real reply key. */
5af5b2
+        errcode = krb5_dbe_decrypt_key_data(kdc_context, NULL, client_key,
5af5b2
+                                            &state->client_keyblock, NULL);
5af5b2
+        if (errcode) {
5af5b2
+            state->status = "DECRYPT_CLIENT_KEY";
5af5b2
+            goto egress;
5af5b2
+        }
5af5b2
+        state->client_keyblock.enctype = useenctype;
5af5b2
+        state->rock.client_key = client_key;
5af5b2
     }
5af5b2
-    state->client_keyblock.enctype = useenctype;
5af5b2
 
5af5b2
     /* Start assembling the response */
5af5b2
     state->reply.msg_type = KRB5_AS_REP;
5af5b2
@@ -248,6 +243,14 @@ finish_process_as_req(struct as_req_state *state, krb5_error_code errcode)
5af5b2
         goto egress;
5af5b2
     }
5af5b2
 
5af5b2
+    /* If we didn't find a client long-term key and no preauth mechanism
5af5b2
+     * replaced the reply key, error out now. */
5af5b2
+    if (state->client_keyblock.enctype == ENCTYPE_NULL) {
5af5b2
+        state->status = "CANT_FIND_CLIENT_KEY";
5af5b2
+        errcode = KRB5KDC_ERR_ETYPE_NOSUPP;
5af5b2
+        goto egress;
5af5b2
+    }
5af5b2
+
5af5b2
     errcode = handle_authdata(kdc_context,
5af5b2
                               state->c_flags,
5af5b2
                               state->client,
5af5b2
@@ -306,7 +309,8 @@ finish_process_as_req(struct as_req_state *state, krb5_error_code errcode)
5af5b2
                                   &state->reply_encpart, 0,
5af5b2
                                   as_encrypting_key,
5af5b2
                                   &state->reply, &response);
5af5b2
-    state->reply.enc_part.kvno = client_key->key_data_kvno;
5af5b2
+    if (client_key != NULL)
5af5b2
+        state->reply.enc_part.kvno = client_key->key_data_kvno;
5af5b2
     if (errcode) {
5af5b2
         state->status = "ENCODE_KDC_REP";
5af5b2
         goto egress;
5af5b2
diff --git a/src/kdc/kdc_preauth.c b/src/kdc/kdc_preauth.c
5af5b2
index 5c3b615..5d12346 100644
5af5b2
--- a/src/kdc/kdc_preauth.c
5af5b2
+++ b/src/kdc/kdc_preauth.c
5af5b2
@@ -1473,6 +1473,9 @@ etype_info_as_rep_helper(krb5_context context, krb5_pa_data * padata,
5af5b2
     krb5_etype_info_entry **entry = NULL;
5af5b2
     krb5_data *scratch = NULL;
5af5b2
 
5af5b2
+    if (client_key == NULL)
5af5b2
+        return 0;
5af5b2
+
5af5b2
     /*
5af5b2
      * Skip PA-ETYPE-INFO completely if AS-REQ lists any "newer"
5af5b2
      * enctypes.
5af5b2
@@ -1576,6 +1579,9 @@ return_pw_salt(krb5_context context, krb5_pa_data *in_padata,
5af5b2
     krb5_key_data *     client_key = rock->client_key;
5af5b2
     int i;
5af5b2
 
5af5b2
+    if (client_key == NULL)
5af5b2
+        return 0;
5af5b2
+
5af5b2
     for (i = 0; i < request->nktypes; i++) {
5af5b2
         if (enctype_requires_etype_info_2(request->ktype[i]))
5af5b2
             return 0;
5af5b2
-- 
5af5b2
1.8.2.1
5af5b2