Merge branch 'master' into tlv-mic
[moonshot.git] / mech_eap / export_sec_context.c
index b242086..91f032f 100644 (file)
@@ -38,7 +38,7 @@
 #include "gssapiP_eap.h"
 
 static OM_uint32
-gssEapExportPartialContext(OM_uint32 *minor,
+exportPartialRadiusContext(OM_uint32 *minor,
                            gss_ctx_id_t ctx,
                            gss_buffer_t token)
 {
@@ -102,8 +102,7 @@ cleanup:
 OM_uint32
 gssEapExportSecContext(OM_uint32 *minor,
                        gss_ctx_id_t ctx,
-                       gss_buffer_t token,
-                       OM_uint32 flags)
+                       gss_buffer_t token)
 {
     OM_uint32 major, tmpMinor;
     size_t length;
@@ -123,13 +122,9 @@ gssEapExportSecContext(OM_uint32 *minor,
     key.value  = KRB_KEY_DATA(&ctx->rfc3961Key);
 
     if (ctx->initiatorName != GSS_C_NO_NAME) {
-        OM_uint32 nameFlags = EXPORT_NAME_FLAG_COMPOSITE;
-
-        if (flags & EXPORT_CTX_FLAG_DISABLE_LOCAL_ATTRS)
-            nameFlags |= EXPORT_NAME_FLAG_DISABLE_LOCAL_ATTRS;
-
         major = gssEapExportNameInternal(minor, ctx->initiatorName,
-                                         &initiatorName, nameFlags);
+                                         &initiatorName,
+                                         EXPORT_NAME_FLAG_COMPOSITE);
         if (GSS_ERROR(major))
             goto cleanup;
     }
@@ -160,6 +155,9 @@ gssEapExportSecContext(OM_uint32 *minor,
     length += 4 + acceptorName.length;          /* acceptorName.value */
     length += 24 + sequenceSize(ctx->seqState); /* seqState */
 
+    if (!CTX_IS_INITIATOR(ctx) && !CTX_IS_ESTABLISHED(ctx))
+        length += 4 + ctx->conversation.length;
+
     if (partialCtx.value != NULL)
         length += 4 + partialCtx.length;        /* partialCtx.value */
 
@@ -195,6 +193,9 @@ gssEapExportSecContext(OM_uint32 *minor,
     if (GSS_ERROR(major))
         goto cleanup;
 
+    if (!CTX_IS_INITIATOR(ctx) && !CTX_IS_ESTABLISHED(ctx))
+        p = store_buffer(&ctx->conversation, &p, FALSE);
+
     if (partialCtx.value != NULL)
         p = store_buffer(&partialCtx, p, FALSE);
 
@@ -233,7 +234,7 @@ gss_export_sec_context(OM_uint32 *minor,
 
     GSSEAP_MUTEX_LOCK(&ctx->mutex);
 
-    major = gssEapExportSecContext(minor, ctx, interprocess_token, 0);
+    major = gssEapExportSecContext(minor, ctx, interprocess_token);
     if (GSS_ERROR(major)) {
         GSSEAP_MUTEX_UNLOCK(&ctx->mutex);
         return major;