add some SASL descriptions
authorLuke Howard <lukeh@padl.com>
Sat, 25 Sep 2010 13:46:34 +0000 (15:46 +0200)
committerLuke Howard <lukeh@padl.com>
Sat, 25 Sep 2010 13:46:34 +0000 (15:46 +0200)
inquire_mech_for_saslname.c
util_mech.c
util_token.c

index f42df28..0d0d60f 100644 (file)
@@ -40,6 +40,24 @@ gss_inquire_saslname_for_mech(OM_uint32 *minor,
                               gss_buffer_t mech_description)
 {
     gss_buffer_t name;
+    krb5_enctype etype = ENCTYPE_NULL;
+    krb5_context krbContext;
+
+    GSSEAP_KRB_INIT(&krbContext);
+
+    makeStringBuffer(minor,
+                    "Extensible Authentication Protocol GSS-API Mechanism",
+                    mech_description);
+
+    /* Dynamically construct mechanism name from Kerberos string enctype */
+    if (oidEqual(mech, GSS_EAP_MECHANISM)) {
+        makeStringBuffer(minor, "eap", mech_name);
+    } else if (gssEapOidToEnctype(minor, mech, &etype) == GSS_S_COMPLETE) {
+        char krbBuf[128] = "eap-";
+
+        if (krb5_enctype_to_name(etype, 0, &krbBuf[4], sizeof(krbBuf) - 4) == 0)
+            makeStringBuffer(minor, krbBuf, mech_name);
+    }
 
     name = gssEapOidToSaslName(mech);
     if (name == GSS_C_NO_BUFFER)
index 1b554c5..9f3cb22 100644 (file)
@@ -263,9 +263,9 @@ gssEapInternalizeOid(const gss_OID oid,
 }
 
 static gss_buffer_desc gssEapSaslMechs[] = {
-    { sizeof("GS2-EAP"), "GS2-EAP", },
-    { sizeof("GS2-EAP-AES128"), "GS2-EAP-AES128" },
-    { sizeof("GS2-EAP-AES256"), "GS2-EAP-AES256" },
+    { sizeof("GS2-EAP") - 1,        "GS2-EAP",       },
+    { sizeof("GS2-EAP-AES128") - 1, "GS2-EAP-AES128" },
+    { sizeof("GS2-EAP-AES256") - 1, "GS2-EAP-AES256" },
 };
 
 gss_buffer_t
index 02d6557..29614fd 100644 (file)
@@ -181,10 +181,9 @@ makeTokenHeader(
     *(*buf)++ = (unsigned char)mech->length;
     memcpy(*buf, mech->elements, mech->length);
     *buf += mech->length;
-    if (tok_type != TOK_TYPE_NONE) {
-        *(*buf)++ = (unsigned char)((tok_type>>8) & 0xff);
-        *(*buf)++ = (unsigned char)(tok_type & 0xff);
-    }
+    assert(tok_type != TOK_TYPE_NONE);
+    *(*buf)++ = (unsigned char)((tok_type>>8) & 0xff);
+    *(*buf)++ = (unsigned char)(tok_type & 0xff);
 }
 
 /*