Fixes for Heimdal (macOS) builds from Stefan.
[mech_eap.git] / mech_eap / export_sec_context.c
index 98003d5..3b74366 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include "gssapiP_eap.h"
+
 #ifdef GSSEAP_ENABLE_ACCEPTOR
 static OM_uint32
 gssEapExportPartialContext(OM_uint32 *minor,
@@ -85,7 +86,7 @@ gssEapExportPartialContext(OM_uint32 *minor,
         p += ctx->acceptorCtx.state.length;
     }
 
-    assert(p == (unsigned char *)token->value + token->length);
+    GSSEAP_ASSERT(p == (unsigned char *)token->value + token->length);
 
     major = GSS_S_COMPLETE;
     *minor = 0;
@@ -120,6 +121,11 @@ gssEapExportSecContext(OM_uint32 *minor,
     key.length = KRB_KEY_LENGTH(&ctx->rfc3961Key);
     key.value  = KRB_KEY_DATA(&ctx->rfc3961Key);
 
+    /*
+     * As a shortcut, we omit the mechanism OID of the initiator name because
+     * we know it will match the context mechanism. The acceptor name mech OID
+     * is always included.
+     */
     if (ctx->initiatorName != GSS_C_NO_NAME) {
         major = gssEapExportNameInternal(minor, ctx->initiatorName,
                                          &initiatorName,
@@ -131,10 +137,11 @@ gssEapExportSecContext(OM_uint32 *minor,
     if (ctx->acceptorName != GSS_C_NO_NAME) {
         major = gssEapExportNameInternal(minor, ctx->acceptorName,
                                          &acceptorName,
-                                         EXPORT_NAME_FLAG_COMPOSITE);
+                                         EXPORT_NAME_FLAG_OID | EXPORT_NAME_FLAG_COMPOSITE);
         if (GSS_ERROR(major))
             goto cleanup;
     }
+
 #ifdef GSSEAP_ENABLE_ACCEPTOR
     /*
      * The partial context is only transmitted for unestablished acceptor
@@ -193,7 +200,7 @@ gssEapExportSecContext(OM_uint32 *minor,
     if (partialCtx.value != NULL)
         p = store_buffer(&partialCtx, p, FALSE);
 
-    assert(p == (unsigned char *)token->value + token->length);
+    GSSEAP_ASSERT(p == (unsigned char *)token->value + token->length);
 
     major = GSS_S_COMPLETE;
     *minor = 0;
@@ -208,7 +215,7 @@ cleanup:
     return major;
 }
 
-OM_uint32 KRB5_CALLCONV
+OM_uint32 GSSAPI_CALLCONV
 gss_export_sec_context(OM_uint32 *minor,
                        gss_ctx_id_t *context_handle,
                        gss_buffer_t interprocess_token)