]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Always use AS-REP enctype in PKINIT client
authorGreg Hudson <ghudson@mit.edu>
Tue, 13 Feb 2018 21:33:33 +0000 (16:33 -0500)
committerGreg Hudson <ghudson@mit.edu>
Mon, 19 Mar 2018 23:37:41 +0000 (19:37 -0400)
The get_etype() callback originally only returned the AS-REP enctype
for PKINIT, but was changed for encrypted challenge to sometimes
return the enctype from etype-info.  (Encrypted challenge no longer
uses the callback; PKINIT is currently the only known consumer.)  Make
sure to always return the AS-REP enctype if an AS-REP has been
received, so that the PKINIT clpreauth module uses the correct enctype
even if the KDC sends a different enctype in etype-info in violation
of RFC 4120.

ticket: 8642

src/include/krb5/clpreauth_plugin.h
src/lib/krb5/krb/preauth2.c

index 0106734ad734f1b34a8fb32cbbc71be41ad0dbad..e47607c4a3ebcc1b78fe5a98e3660faa78bcb137 100644 (file)
@@ -84,10 +84,9 @@ typedef struct krb5_clpreauth_callbacks_st {
     int vers;
 
     /*
-     * Get the enctype expected to be used to encrypt the encrypted portion of
-     * the AS_REP packet.  When handling a PREAUTH_REQUIRED error, this
-     * typically comes from etype-info2.  When handling an AS reply, it is
-     * initialized from the AS reply itself.
+     * If an AS-REP has been received, return the enctype of the AS-REP
+     * encrypted part.  Otherwise return the enctype chosen from etype-info, or
+     * the first requested enctype if no etype-info was received.
      */
     krb5_enctype (*get_etype)(krb5_context context, krb5_clpreauth_rock rock);
 
index 6b96fa135e1a06b45238bbaac05bbe363760b93b..243a2084cffbf1fb83d7a9a8f08f1c3312f478d0 100644 (file)
@@ -428,7 +428,11 @@ grow_pa_list(krb5_pa_data ***out_pa_list, int *out_pa_list_size,
 static krb5_enctype
 get_etype(krb5_context context, krb5_clpreauth_rock rock)
 {
-    return ((krb5_init_creds_context)rock)->etype;
+    krb5_init_creds_context ctx = (krb5_init_creds_context)rock;
+
+    if (ctx->reply != NULL)
+        return ctx->reply->enc_part.enctype;
+    return ctx->etype;
 }
 
 static krb5_keyblock *