Implemented callback in libeap/src/crypto to allow mech_eap / ID Selector to ask...
[mech_eap.git] / mech_eap / inquire_context.c
index 0e7b586..5d0e5b6 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "gssapiP_eap.h"
 
-OM_uint32
+OM_uint32 GSSAPI_CALLCONV
 gss_inquire_context(OM_uint32 *minor,
                     gss_ctx_id_t ctx,
                     gss_name_t *src_name,
@@ -57,31 +57,25 @@ gss_inquire_context(OM_uint32 *minor,
     GSSEAP_MUTEX_LOCK(&ctx->mutex);
 
     if (src_name != NULL) {
-        major = gssEapDuplicateName(minor, ctx->initiatorName, src_name);
-        if (GSS_ERROR(major))
-            goto cleanup;
+        if (ctx->initiatorName != GSS_C_NO_NAME) {
+            major = gssEapDuplicateName(minor, ctx->initiatorName, src_name);
+            if (GSS_ERROR(major))
+                goto cleanup;
+        } else
+            *src_name = GSS_C_NO_NAME;
     }
 
     if (targ_name != NULL) {
-        major = gssEapDuplicateName(minor, ctx->acceptorName, targ_name);
-        if (GSS_ERROR(major))
-            goto cleanup;
+        if (ctx->acceptorName != GSS_C_NO_NAME) {
+            major = gssEapDuplicateName(minor, ctx->acceptorName, targ_name);
+            if (GSS_ERROR(major))
+                goto cleanup;
+        } else
+            *targ_name = GSS_C_NO_NAME;
     }
 
-    if (lifetime_rec != NULL) {
-        time_t now, lifetime;
-
-        if (ctx->expiryTime == 0) {
-            lifetime = GSS_C_INDEFINITE;
-        } else {
-            now = time(NULL);
-            lifetime = now - ctx->expiryTime;
-            if (lifetime < 0)
-                lifetime = 0;
-        }
-
-        *lifetime_rec = lifetime;
-    }
+    if (lifetime_rec != NULL)
+        gssEapContextTime(&tmpMinor, ctx, lifetime_rec);
 
     if (mech_type != NULL) {
         major = gssEapCanonicalizeOid(minor, ctx->mechanismUsed, 0, mech_type);