Add mech name OID, gss_display_name implementation
[mech_eap.git] / util_context.c
index 7121d7f..b6dec71 100644 (file)
@@ -47,8 +47,8 @@ gssEapAllocContext(OM_uint32 *minor,
         return GSS_S_FAILURE;
     }
 
-    *minor = krb5_init_context(&ctx->kerberosCtx);
-    if (*minor != 0) {
+    if (GSSEAP_MUTEX_INIT(&ctx->mutex) != 0) {
+        *minor = errno;
         gssEapReleaseContext(&tmpMinor, &ctx);
         return GSS_S_FAILURE;
     }
@@ -76,27 +76,27 @@ gssEapReleaseContext(OM_uint32 *minor,
 {
     OM_uint32 major, tmpMinor;
     gss_ctx_id_t ctx = *pCtx;
+    krb5_context krbContext = NULL;
 
     if (ctx == GSS_C_NO_CONTEXT) {
         return GSS_S_COMPLETE;
     }
 
+    gssEapKerberosInit(&tmpMinor, &krbContext);
+
     if (CTX_IS_INITIATOR(ctx)) {
         releaseInitiatorContext(&ctx->initiatorCtx);
     } else {
         releaseAcceptorContext(&ctx->acceptorCtx);
     }
 
-    if (ctx->encryptionKey != NULL) {
-        krb5_free_keyblock(ctx->kerberosCtx, ctx->encryptionKey);
-    }
-
-    if (ctx->kerberosCtx != NULL) {
-        krb5_free_context(ctx->kerberosCtx);
-    }
-
+    krb5_free_keyblock_contents(krbContext, &ctx->rfc3961Key);
     gssEapReleaseName(&tmpMinor, &ctx->initiatorName);
     gssEapReleaseName(&tmpMinor, &ctx->acceptorName);
+    gss_release_oid(&tmpMinor, &ctx->mechanismUsed);
+    sequenceFree(ctx->seqState);
+
+    GSSEAP_MUTEX_DESTROY(&ctx->mutex);
 
     memset(ctx, 0, sizeof(*ctx));
     GSSEAP_FREE(ctx);