gss_cred_id_t cred,
gss_ctx_id_t ctx)
{
+ OM_uint32 major;
krb5_context krbContext;
struct eap_peer_config *eapPeerConfig = &ctx->initiatorCtx.eapPeerConfig;
- krb5_error_code code;
- char *identity, *anonymousIdentity;
+ gss_buffer_desc identity = GSS_C_EMPTY_BUFFER;
+ gss_buffer_desc anonymousIdentity = GSS_C_EMPTY_BUFFER;
+ ssize_t i;
eapPeerConfig->identity = NULL;
eapPeerConfig->identity_len = 0;
+ eapPeerConfig->anonymous_identity = NULL;
+ eapPeerConfig->anonymous_identity_len = 0;
eapPeerConfig->password = NULL;
eapPeerConfig->password_len = 0;
return GSS_S_BAD_NAME;
}
- code = krb5_unparse_name(krbContext, cred->name->krbPrincipal, &identity);
- if (code != 0) {
- *minor = code;
- return GSS_S_FAILURE;
+ major = gssEapDisplayName(minor, cred->name, &identity, NULL);
+ if (GSS_ERROR(major))
+ return major;
+
+ assert(identity.length > 0);
+
+ for (i = identity.length - 1; i >= 0; i--) {
+ unsigned char *p = (unsigned char *)identity.value + i;
+
+ if (*p == '@') {
+ anonymousIdentity.length = identity.length - i;
+ anonymousIdentity.value = p;
+ break;
+ }
}
- anonymousIdentity = strchr(identity, '@');
- if (anonymousIdentity == NULL)
- anonymousIdentity = "";
+ if (anonymousIdentity.length == 0)
+ anonymousIdentity.value = "";
- eapPeerConfig->identity = (unsigned char *)identity;
- eapPeerConfig->identity_len = strlen(identity);
- eapPeerConfig->anonymous_identity = (unsigned char *)anonymousIdentity;
- eapPeerConfig->anonymous_identity_len = strlen(anonymousIdentity);
+ eapPeerConfig->identity = (unsigned char *)identity.value;
+ eapPeerConfig->identity_len = identity.length;
+ eapPeerConfig->anonymous_identity = (unsigned char *)anonymousIdentity.value;
+ eapPeerConfig->anonymous_identity_len = anonymousIdentity.length;
eapPeerConfig->password = (unsigned char *)cred->password.value;
eapPeerConfig->password_len = cred->password.length;
peerConfigFree(OM_uint32 *minor,
gss_ctx_id_t ctx)
{
- krb5_context krbContext;
struct eap_peer_config *eapPeerConfig = &ctx->initiatorCtx.eapPeerConfig;
- GSSEAP_KRB_INIT(&krbContext);
-
- krb5_free_unparsed_name(krbContext, (char *)eapPeerConfig->identity);
+ GSSEAP_FREE(eapPeerConfig->identity);
*minor = 0;
return GSS_S_COMPLETE;
GSSEAP_MUTEX_UNLOCK(&target->mutex);
}
- if (mech == GSS_C_NULL_OID) {
- major = gssEapDefaultMech(minor, &ctx->mechanismUsed);
- } else if (gssEapIsConcreteMechanismOid(mech)) {
- if (!gssEapInternalizeOid(mech, &ctx->mechanismUsed))
- major = duplicateOid(minor, mech, &ctx->mechanismUsed);
- } else {
- major = GSS_S_BAD_MECH;
- *minor = GSSEAP_WRONG_MECH;
- }
+ major = gssEapCanonicalizeOid(minor,
+ mech,
+ OID_FLAG_NULL_VALID | OID_FLAG_MAP_NULL_TO_DEFAULT_MECH,
+ &ctx->mechanismUsed);
if (GSS_ERROR(major))
return major;
goto cleanup;
if (actual_mech_type != NULL) {
- if (!gssEapInternalizeOid(ctx->mechanismUsed, actual_mech_type))
- duplicateOid(&tmpMinor, ctx->mechanismUsed, actual_mech_type);
+ OM_uint32 tmpMajor;
+
+ tmpMajor = gssEapCanonicalizeOid(&tmpMinor, ctx->mechanismUsed, 0, actual_mech_type);
+ if (GSS_ERROR(tmpMajor)) {
+ major = tmpMajor;
+ *minor = tmpMinor;
+ goto cleanup;
+ }
}
if (ret_flags != NULL)
*ret_flags = ctx->gssFlags;