]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Add kdcpreauth callback to check for client keys
authorGreg Hudson <ghudson@mit.edu>
Fri, 26 Apr 2013 19:50:05 +0000 (15:50 -0400)
committerGreg Hudson <ghudson@mit.edu>
Fri, 3 May 2013 20:11:28 +0000 (16:11 -0400)
Add a new have_client_keys callback to the kdcpreauth interface,
allowing modules to efficiently check whether the client DB entry has
any keys matching the request enctypes.

ticket: 7630

src/include/krb5/kdcpreauth_plugin.h
src/kdc/kdc_preauth.c

index e673d4003559cf018167160ba0fdfc114321a5a4..9abe76f6345136f11c02456c05877d310d268200 100644 (file)
@@ -173,6 +173,14 @@ typedef struct krb5_kdcpreauth_callbacks_st {
                                        krb5_kdcpreauth_rock rock);
 
     /* End of version 1 kdcpreauth callbacks. */
+
+    /* Return true if the client DB entry contains any keys matching the
+     * request enctypes. */
+    krb5_boolean (*have_client_keys)(krb5_context context,
+                                     krb5_kdcpreauth_rock rock);
+
+    /* End of version 2 kdcpreauth callbacks. */
+
 } *krb5_kdcpreauth_callbacks;
 
 /* Optional: preauth plugin initialization function. */
index c2bcab9f3bc6020032289341947d8157dbfd668f..b7f9e151440d1debc0c83b1d3abae375049a5cb6 100644 (file)
@@ -542,8 +542,23 @@ event_context(krb5_context context, krb5_kdcpreauth_rock rock)
     return rock->vctx;
 }
 
+static krb5_boolean
+have_client_keys(krb5_context context, krb5_kdcpreauth_rock rock)
+{
+    krb5_kdc_req *request = rock->request;
+    krb5_key_data *kd;
+    int i;
+
+    for (i = 0; i < request->nktypes; i++) {
+        if (krb5_dbe_find_enctype(context, rock->client, request->ktype[i],
+                                  -1, 0, &kd) == 0)
+            return TRUE;
+    }
+    return FALSE;
+}
+
 static struct krb5_kdcpreauth_callbacks_st callbacks = {
-    1,
+    2,
     max_time_skew,
     client_keys,
     free_keys,
@@ -552,7 +567,8 @@ static struct krb5_kdcpreauth_callbacks_st callbacks = {
     get_string,
     free_string,
     client_entry,
-    event_context
+    event_context,
+    have_client_keys
 };
 
 static krb5_error_code