/*
- * Copyright (c) 2010, JANET(UK)
+ * Copyright (c) 2011, JANET(UK)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
if (GSS_ERROR(major))
return major;
- ctx->initiatorName->attrCtx = gssEapCreateAttrContext(cred, ctx);
+ major = gssEapCreateAttrContext(minor, cred, ctx,
+ &ctx->initiatorName->attrCtx,
+ &ctx->expiryTime);
+ if (GSS_ERROR(major))
+ return major;
*minor = 0;
return GSS_S_COMPLETE;
assert(ctx->acceptorName == GSS_C_NO_NAME);
- if (cred != GSS_C_NO_CREDENTIAL && cred->name != GSS_C_NO_NAME) {
+ if (cred->name != GSS_C_NO_NAME) {
major = gssEapDuplicateName(minor, cred->name, &ctx->acceptorName);
if (GSS_ERROR(major))
return major;
if (GSS_ERROR(major))
return major;
- ctx->state = EAP_STATE_AUTHENTICATE;
+ ctx->state = GSSEAP_STATE_AUTHENTICATE;
*minor = 0;
return GSS_S_CONTINUE_NEEDED;
krbPrinc = ctx->acceptorName->krbPrincipal;
assert(krbPrinc != NULL);
- assert(krb5_princ_size(krbContext, krbPrinc) >= 2);
+ assert(KRB_PRINC_LENGTH(krbPrinc) >= 2);
/* Acceptor-Service-Name */
- krbDataToGssBuffer(krb5_princ_component(krbContext, krbPrinc, 0), &nameBuf);
+ krbPrincComponentToGssBuffer(krbPrinc, 0, &nameBuf);
major = gssEapRadiusAddAvp(minor, vps,
PW_GSS_ACCEPTOR_SERVICE_NAME,
return major;
/* Acceptor-Host-Name */
- krbDataToGssBuffer(krb5_princ_component(krbContext, krbPrinc, 1), &nameBuf);
+ krbPrincComponentToGssBuffer(krbPrinc, 1, &nameBuf);
major = gssEapRadiusAddAvp(minor, vps,
PW_GSS_ACCEPTOR_HOST_NAME,
if (GSS_ERROR(major))
return major;
- if (krb5_princ_size(krbContext, krbPrinc) > 2) {
+ if (KRB_PRINC_LENGTH(krbPrinc) > 2) {
/* Acceptor-Service-Specific */
krb5_principal_data ssiPrinc = *krbPrinc;
char *ssi;
- krb5_princ_size(krbContext, &ssiPrinc) -= 2;
- krb5_princ_name(krbContext, &ssiPrinc) += 2;
+ KRB_PRINC_LENGTH(&ssiPrinc) -= 2;
+ KRB_PRINC_NAME(&ssiPrinc) += 2;
*minor = krb5_unparse_name_flags(krbContext, &ssiPrinc,
KRB5_PRINCIPAL_UNPARSE_NO_REALM, &ssi);
krb5_free_unparsed_name(krbContext, ssi);
}
- krbDataToGssBuffer(krb5_princ_realm(krbContext, krbPrinc), &nameBuf);
+ krbPrincRealmToGssBuffer(krbPrinc, &nameBuf);
if (nameBuf.length != 0) {
/* Acceptor-Realm-Name */
major = gssEapRadiusAddAvp(minor, vps,
return GSS_S_FAILURE;
}
- if (cred != GSS_C_NO_CREDENTIAL) {
- if (cred->radiusConfigFile != NULL)
- configFile = cred->radiusConfigFile;
- if (cred->radiusConfigStanza != NULL)
- configStanza = cred->radiusConfigStanza;
- }
+ if (cred->radiusConfigFile != NULL)
+ configFile = cred->radiusConfigFile;
+ if (cred->radiusConfigStanza != NULL)
+ configStanza = cred->radiusConfigStanza;
ralloc.calloc = GSSEAP_CALLOC;
ralloc.malloc = GSSEAP_MALLOC;
goto fail;
}
- /* XXX TODO rs_conn_select_server does not exist yet */
-#if 0
if (actx->radServer != NULL) {
if (rs_conn_select_server(actx->radConn, actx->radServer) != 0) {
err = rs_err_conn_pop(actx->radConn);
goto fail;
}
}
-#endif
*minor = 0;
return GSS_S_COMPLETE;
rconn = ctx->acceptorCtx.radConn;
- if (rs_packet_create_acc_request(rconn, &req, NULL, NULL) != 0) {
+ if (rs_packet_create_auth_request(rconn, &req, NULL, NULL) != 0) {
major = gssEapRadiusMapError(minor, rs_err_conn_pop(rconn));
goto cleanup;
}
if (GSS_ERROR(major))
goto cleanup;
- ctx->state = EAP_STATE_EXTENSIONS_REQ;
+ ctx->state = GSSEAP_STATE_EXTENSIONS_REQ;
}
*minor = 0;
major = GSS_S_CONTINUE_NEEDED;
cleanup:
- rs_request_destroy(request);
+ if (request)
+ rs_request_destroy(request);
return major;
}
outputToken->length = 0;
outputToken->value = NULL;
- ctx->state = EAP_STATE_EXTENSIONS_RESP;
+ ctx->state = GSSEAP_STATE_EXTENSIONS_RESP;
*minor = 0;
return GSS_S_CONTINUE_NEEDED;
if (GSS_ERROR(major))
return major;
- ctx->state = EAP_STATE_ESTABLISHED;
+ ctx->state = GSSEAP_STATE_ESTABLISHED;
*minor = 0;
return GSS_S_COMPLETE;
* Only return error codes that the initiator could have caused,
* to avoid information leakage.
*/
- switch (minorStatus) {
- case GSSEAP_WRONG_SIZE:
- case GSSEAP_WRONG_MECH:
- case GSSEAP_BAD_TOK_HEADER:
- case GSSEAP_TOK_TRUNC:
- case GSSEAP_BAD_DIRECTION:
- case GSSEAP_WRONG_TOK_ID:
- case GSSEAP_REFLECT:
- case GSSEAP_CRIT_EXT_UNAVAILABLE:
- case GSSEAP_MISSING_REQUIRED_EXT:
- case GSSEAP_KEY_UNAVAILABLE:
- case GSSEAP_KEY_TOO_SHORT:
- case GSSEAP_RADIUS_AUTH_FAILURE:
- case GSSEAP_UNKNOWN_RADIUS_CODE:
- case GSSEAP_MISSING_EAP_REQUEST:
- break;
- default:
- if (IS_RADIUS_ERROR(minorStatus))
- /* Squash RADIUS error codes */
- minorStatus = GSSEAP_GENERIC_RADIUS_ERROR;
- else
- /* Don't return system error codes */
- return GSS_S_COMPLETE;
+ if (IS_RADIUS_ERROR(minorStatus)) {
+ /* Squash RADIUS error codes */
+ minorStatus = GSSEAP_RADIUS_PROT_FAILURE;
+ } else if (!IS_WIRE_ERROR(minorStatus)) {
+ /* Don't return non-wire error codes */
+ return GSS_S_COMPLETE;
}
minorStatus -= ERROR_TABLE_BASE_eapg;
GSSEAP_MUTEX_LOCK(&ctx->mutex);
- /* Validate and lock credentials */
- if (cred != GSS_C_NO_CREDENTIAL) {
- GSSEAP_MUTEX_LOCK(&cred->mutex);
-
- if ((cred->flags & CRED_FLAG_ACCEPT) == 0) {
- *minor = GSSEAP_CRED_USAGE_MISMATCH;
- major = GSS_S_NO_CRED;
- goto cleanup;
+ if (cred == GSS_C_NO_CREDENTIAL) {
+ if (ctx->defaultCred == GSS_C_NO_CREDENTIAL) {
+ major = gssEapAcquireCred(minor,
+ GSS_C_NO_NAME,
+ GSS_C_NO_BUFFER,
+ GSS_C_INDEFINITE,
+ GSS_C_NO_OID_SET,
+ GSS_C_ACCEPT,
+ &ctx->defaultCred,
+ NULL,
+ NULL);
+ if (GSS_ERROR(major))
+ goto cleanup;
}
+
+ cred = ctx->defaultCred;
}
+ GSSEAP_MUTEX_LOCK(&cred->mutex);
+
sm = &eapGssAcceptorSm[ctx->state];
major = gssEapVerifyToken(minor, ctx, input_token,
* machine and process Kerberos GSS messages instead.
*/
if (tokType == TOK_TYPE_GSS_REAUTH && initialContextToken) {
- ctx->state = EAP_STATE_KRB_REAUTH_GSS;
+ ctx->state = GSSEAP_STATE_KRB_REAUTH;
} else
#endif
if (tokType != sm->inputTokenType) {
goto cleanup;
}
- sm = &eapGssAcceptorSm[EAP_STATE_ERROR];
+ sm = &eapGssAcceptorSm[GSSEAP_STATE_ERROR];
goto send_token;
}
} while (major == GSS_S_CONTINUE_NEEDED && innerOutputToken.length == 0);
}
}
- assert(ctx->state == EAP_STATE_ESTABLISHED || major == GSS_S_CONTINUE_NEEDED);
+ assert(ctx->state == GSSEAP_STATE_ESTABLISHED || major == GSS_S_CONTINUE_NEEDED);
send_token:
if (innerOutputToken.value != NULL) {
{
OM_uint32 major;
- major = gssEapGlueToMechName(minor, initiator, &ctx->initiatorName);
+ major = gssEapGlueToMechName(minor, ctx, initiator, &ctx->initiatorName);
if (GSS_ERROR(major))
return major;
- if (cred != GSS_C_NO_CREDENTIAL && cred->name != GSS_C_NO_NAME) {
+ if (cred->name != GSS_C_NO_NAME) {
major = gssEapDuplicateName(minor, cred->name, &ctx->acceptorName);
if (GSS_ERROR(major))
return major;
if (GSS_ERROR(major))
return major;
- ctx->state = EAP_STATE_ESTABLISHED;
+ ctx->state = GSSEAP_STATE_ESTABLISHED;
*minor = 0;
return GSS_S_COMPLETE;
gss_buffer_t outputToken)
{
OM_uint32 major, tmpMinor;
- gss_cred_id_t krbCred = GSS_C_NO_CREDENTIAL;
gss_name_t krbInitiator = GSS_C_NO_NAME;
gss_OID mech = GSS_C_NO_OID;
OM_uint32 gssFlags, timeRec = GSS_C_INDEFINITE;
- ctx->flags |= CTX_FLAG_KRB_REAUTH_GSS;
-
- if (cred != GSS_C_NO_CREDENTIAL)
- krbCred = cred->krbCred;
+ ctx->flags |= CTX_FLAG_KRB_REAUTH;
major = gssAcceptSecContext(minor,
&ctx->kerberosCtx,
- krbCred,
+ cred->krbCred,
inputToken,
chanBindings,
&krbInitiator,