cleanup, plugin attr context
authorLuke Howard <lukeh@padl.com>
Tue, 21 Sep 2010 06:38:40 +0000 (08:38 +0200)
committerLuke Howard <lukeh@padl.com>
Tue, 21 Sep 2010 06:38:40 +0000 (08:38 +0200)
mech_eap/accept_sec_context.c
mech_eap/init_sec_context.c
mech_eap/util_radius.cpp
mech_eap/util_radius.h

index ecea6ec..a95a116 100644 (file)
@@ -38,7 +38,7 @@
  * Mark a context as ready for cryptographic operations
  */
 static OM_uint32
-acceptReady(OM_uint32 *minor, gss_ctx_id_t ctx)
+acceptReady(OM_uint32 *minor, gss_ctx_id_t ctx, gss_cred_id_t cred)
 {
     OM_uint32 major;
     VALUE_PAIR *vp;
@@ -65,6 +65,8 @@ acceptReady(OM_uint32 *minor, gss_ctx_id_t ctx)
             return major;
     }
 
+    ctx->initiatorName->attrCtx = gssEapCreateAttrContext(cred, ctx);
+
     vp = rc_avpair_get(ctx->acceptorCtx.avps, 0x01370010, 0);
     if (ctx->encryptionType != ENCTYPE_NULL && vp != NULL) {
         major = gssEapDeriveRfc3961Key(minor,
@@ -86,6 +88,7 @@ acceptReady(OM_uint32 *minor, gss_ctx_id_t ctx)
          * material it seems confusing to the caller to advertise this.
          */
         ctx->gssFlags &= ~(GSS_C_INTEG_FLAG | GSS_C_CONF_FLAG);
+        ctx->encryptionType = ENCTYPE_NULL;
     }
 
     major = sequenceInit(minor,
@@ -270,7 +273,7 @@ eapGssSmAcceptAuthenticate(OM_uint32 *minor,
         ctx->acceptorCtx.avps = received;
         received = NULL;
 
-        major = acceptReady(minor, ctx);
+        major = acceptReady(minor, ctx, cred);
         if (GSS_ERROR(major))
             goto cleanup;
 
index b386c96..8fdd55d 100644 (file)
@@ -260,6 +260,7 @@ initReady(OM_uint32 *minor, gss_ctx_id_t ctx)
          * material it seems confusing to the caller to advertise this.
          */
         ctx->gssFlags &= ~(GSS_C_INTEG_FLAG | GSS_C_CONF_FLAG);
+        ctx->encryptionType = ENCTYPE_NULL;
     }
 
     major = sequenceInit(minor,
index 97dee6e..86fa8cd 100644 (file)
@@ -154,6 +154,60 @@ gss_eap_radius_attr_provider::createAttrContext(void)
 }
 
 OM_uint32
+addAvpFromBuffer(OM_uint32 *minor,
+                 rc_handle *rh,
+                 VALUE_PAIR **vp,
+                 int type,
+                 gss_buffer_t buffer)
+{
+    if (rc_avpair_add(rh, vp, type, buffer->value, buffer->length, 0) == NULL) {
+        return GSS_S_FAILURE;
+    }
+
+    return GSS_S_COMPLETE;
+}
+
+OM_uint32
+getBufferFromAvps(OM_uint32 *minor,
+                  VALUE_PAIR *vps,
+                  int type,
+                  gss_buffer_t buffer,
+                  int concat)
+{
+    VALUE_PAIR *vp;
+    unsigned char *p;
+
+    buffer->length = 0;
+    buffer->value = NULL;
+
+    vp = rc_avpair_get(vps, type, 0);
+    if (vp == NULL)
+        return GSS_S_UNAVAILABLE;
+
+    do {
+        buffer->length += vp->lvalue;
+    } while (concat && (vp = rc_avpair_get(vp->next, type, 0)) != NULL);
+
+    buffer->value = GSSEAP_MALLOC(buffer->length);
+    if (buffer->value == NULL) {
+        *minor = ENOMEM;
+        return GSS_S_FAILURE;
+    }
+
+    p = (unsigned char *)buffer->value;
+
+    for (vp = rc_avpair_get(vps, type, 0);
+         concat && vp != NULL;
+         vp = rc_avpair_get(vp->next, type, 0)) {
+        memcpy(p, vp->strvalue, vp->lvalue);
+        p += vp->lvalue;
+    }
+
+    *minor = 0;
+    return GSS_S_COMPLETE;
+}
+
+OM_uint32
 gssEapRadiusAttrProviderInit(OM_uint32 *minor)
 {
     return gss_eap_radius_attr_provider::init()
index 6d89c1b..bb9875d 100644 (file)
@@ -90,59 +90,19 @@ private:
 extern "C" {
 #endif
 
-static inline OM_uint32
+OM_uint32
 addAvpFromBuffer(OM_uint32 *minor,
                  rc_handle *rh,
                  VALUE_PAIR **vp,
                  int type,
-                 gss_buffer_t buffer)
-{
-    if (rc_avpair_add(rh, vp, type, buffer->value, buffer->length, 0) == NULL) {
-        return GSS_S_FAILURE;
-    }
+                 gss_buffer_t buffer);
 
-    return GSS_S_COMPLETE;
-}
-
-static inline OM_uint32
+OM_uint32
 getBufferFromAvps(OM_uint32 *minor,
                   VALUE_PAIR *vps,
                   int type,
                   gss_buffer_t buffer,
-                  int concat)
-{
-    VALUE_PAIR *vp;
-    unsigned char *p;
-
-    buffer->length = 0;
-    buffer->value = NULL;
-
-    vp = rc_avpair_get(vps, type, 0);
-    if (vp == NULL)
-        return GSS_S_UNAVAILABLE;
-
-    do {
-        buffer->length += vp->lvalue;
-    } while (concat && (vp = rc_avpair_get(vp->next, type, 0)) != NULL);
-    
-    buffer->value = GSSEAP_MALLOC(buffer->length);
-    if (buffer->value == NULL) {
-        *minor = ENOMEM;
-        return GSS_S_FAILURE;
-    }
-
-    p = (unsigned char *)buffer->value;
-
-    for (vp = rc_avpair_get(vps, type, 0);
-         concat && vp != NULL;
-         vp = rc_avpair_get(vp->next, type, 0)) {
-        memcpy(p, vp->strvalue, vp->lvalue);
-        p += vp->lvalue;
-    }
-
-    *minor = 0;
-    return GSS_S_COMPLETE;
-}
+                  int concat);
 
 OM_uint32 gssEapRadiusAttrProviderInit(OM_uint32 *minor);
 OM_uint32 gssEapRadiusAttrProviderFinalize(OM_uint32 *minor);