if (ctx == GSS_C_NO_CONTEXT)
return FALSE;
- assert(CTX_IS_INITIATOR(ctx));
+ GSSEAP_ASSERT(CTX_IS_INITIATOR(ctx));
switch (variable) {
case EAPOL_idleWhile:
if (ctx == GSS_C_NO_CONTEXT)
return;
- assert(CTX_IS_INITIATOR(ctx));
+ GSSEAP_ASSERT(CTX_IS_INITIATOR(ctx));
switch (variable) {
case EAPOL_idleWhile:
}
static const struct wpa_config_blob *
-peerGetConfigBlob(void *ctx GSSEAP_UNUSED,
- const char *name GSSEAP_UNUSED)
+peerGetConfigBlob(void *ctx,
+ const char *name)
{
- return NULL;
+ gss_ctx_id_t gssCtx = (gss_ctx_id_t)ctx;
+ size_t index;
+
+ if (strcmp(name, "client-cert") == 0)
+ index = CONFIG_BLOB_CLIENT_CERT;
+ else if (strcmp(name, "private-key") == 0)
+ index = CONFIG_BLOB_PRIVATE_KEY;
+ else
+ return NULL;
+
+ return &gssCtx->initiatorCtx.configBlobs[index];
}
static void
OM_uint32 major;
krb5_context krbContext;
struct eap_peer_config *eapPeerConfig = &ctx->initiatorCtx.eapPeerConfig;
+ struct wpa_config_blob *configBlobs = ctx->initiatorCtx.configBlobs;
gss_buffer_desc identity = GSS_C_EMPTY_BUFFER;
gss_buffer_desc realm = GSS_C_EMPTY_BUFFER;
gss_cred_id_t cred = ctx->cred;
eapPeerConfig->password = NULL;
eapPeerConfig->password_len = 0;
- assert(cred != GSS_C_NO_CREDENTIAL);
+ GSSEAP_ASSERT(cred != GSS_C_NO_CREDENTIAL);
GSSEAP_KRB_INIT(&krbContext);
wpa_debug_level = 0;
#endif
- assert(cred->name != GSS_C_NO_NAME);
+ GSSEAP_ASSERT(cred->name != GSS_C_NO_NAME);
if ((cred->name->flags & (NAME_FLAG_NAI | NAME_FLAG_SERVICE)) == 0) {
*minor = GSSEAP_BAD_INITIATOR_NAME;
eapPeerConfig->anonymous_identity_len = 1 + realm.length;
/* password */
- eapPeerConfig->password = (unsigned char *)cred->password.value;
- eapPeerConfig->password_len = cred->password.length;
+ if ((cred->flags & CRED_FLAG_CERTIFICATE) == 0) {
+ eapPeerConfig->password = (unsigned char *)cred->password.value;
+ eapPeerConfig->password_len = cred->password.length;
+ }
/* certs */
eapPeerConfig->ca_cert = (unsigned char *)cred->caCertificate.value;
eapPeerConfig->subject_match = (unsigned char *)cred->subjectNameConstraint.value;
eapPeerConfig->altsubject_match = (unsigned char *)cred->subjectAltNameConstraint.value;
+ if (cred->flags & CRED_FLAG_CERTIFICATE) {
+ /*
+ * CRED_FLAG_CONFIG_BLOB is an internal flag which will be used in the
+ * future to directly pass certificate and private key data to the
+ * EAP implementation, rather than an indirected string pointer.
+ */
+ if (cred->flags & CRED_FLAG_CONFIG_BLOB) {
+ eapPeerConfig->client_cert = (unsigned char *)"blob://client-cert";
+ configBlobs[CONFIG_BLOB_CLIENT_CERT].data = cred->clientCertificate.value;
+ configBlobs[CONFIG_BLOB_CLIENT_CERT].len = cred->clientCertificate.length;
+
+ eapPeerConfig->client_cert = (unsigned char *)"blob://private-key";
+ configBlobs[CONFIG_BLOB_PRIVATE_KEY].data = cred->clientCertificate.value;
+ configBlobs[CONFIG_BLOB_PRIVATE_KEY].len = cred->privateKey.length;
+ } else {
+ eapPeerConfig->client_cert = (unsigned char *)cred->clientCertificate.value;
+ eapPeerConfig->private_key = (unsigned char *)cred->privateKey.value;
+ }
+ eapPeerConfig->private_key_passwd = (unsigned char *)cred->password.value;
+ }
+
*minor = 0;
return GSS_S_COMPLETE;
}
OM_uint32 major;
gss_cred_id_t cred = ctx->cred;
- assert(cred != GSS_C_NO_CREDENTIAL);
+ GSSEAP_ASSERT(cred != GSS_C_NO_CREDENTIAL);
if (cred->expiryTime)
ctx->expiryTime = cred->expiryTime;
*minor = GSSEAP_BAD_ERROR_TOKEN;
}
- assert(GSS_ERROR(major));
+ GSSEAP_ASSERT(GSS_ERROR(major));
return major;
}
gss_OID actualMech = GSS_C_NO_OID;
OM_uint32 gssFlags, timeRec;
- assert(cred != GSS_C_NO_CREDENTIAL);
-
+ /*
+ * Here we use the passed in credential handle because the resolved
+ * context credential does not currently have the reauth creds.
+ */
if (GSSEAP_SM_STATE(ctx) == GSSEAP_STATE_INITIAL) {
if (!gssEapCanReauthP(cred, target, timeReq))
return GSS_S_CONTINUE_NEEDED;
goto cleanup;
}
+ GSSEAP_ASSERT(cred != GSS_C_NO_CREDENTIAL);
+
major = gssEapMechToGlueName(minor, target, &mechTarget);
if (GSS_ERROR(major))
goto cleanup;
ctx->gssFlags = gssFlags;
if (major == GSS_S_COMPLETE) {
- assert(GSSEAP_SM_STATE(ctx) == GSSEAP_STATE_REAUTHENTICATE);
+ GSSEAP_ASSERT(GSSEAP_SM_STATE(ctx) == GSSEAP_STATE_REAUTHENTICATE);
major = gssEapReauthComplete(minor, ctx, cred, actualMech, timeRec);
if (GSS_ERROR(major))
#endif
*smFlags |= SM_FLAG_FORCE_SEND_TOKEN;
- assert((ctx->flags & CTX_FLAG_KRB_REAUTH) == 0);
- assert(inputToken == GSS_C_NO_BUFFER);
+ GSSEAP_ASSERT((ctx->flags & CTX_FLAG_KRB_REAUTH) == 0);
+ GSSEAP_ASSERT(inputToken == GSS_C_NO_BUFFER);
memset(&eapConfig, 0, sizeof(eapConfig));
*minor = 0;
- assert(inputToken != GSS_C_NO_BUFFER);
+ GSSEAP_ASSERT(inputToken != GSS_C_NO_BUFFER);
major = peerConfigInit(minor, ctx);
if (GSS_ERROR(major))
goto cleanup;
- assert(ctx->initiatorCtx.eap != NULL);
- assert(ctx->flags & CTX_FLAG_EAP_PORT_ENABLED);
+ GSSEAP_ASSERT(ctx->initiatorCtx.eap != NULL);
+ GSSEAP_ASSERT(ctx->flags & CTX_FLAG_EAP_PORT_ENABLED);
ctx->flags |= CTX_FLAG_EAP_REQ; /* we have a Request from the acceptor */
OM_uint32 tmpMajor;
gss_buffer_desc respBuf;
- assert(major == GSS_S_CONTINUE_NEEDED);
+ GSSEAP_ASSERT(major == GSS_S_CONTINUE_NEEDED);
respBuf.length = wpabuf_len(resp);
respBuf.value = (void *)wpabuf_head(resp);
if (GSS_ERROR(major))
return major;
- assert(outputToken->value != NULL);
+ GSSEAP_ASSERT(outputToken->value != NULL);
*minor = 0;
*smFlags |= SM_FLAG_OUTPUT_TOKEN_CRITICAL;
OM_uint32 major, tmpMinor;
int initialContextToken = (ctx->mechanismUsed == GSS_C_NO_OID);
+ /*
+ * XXX is acquiring the credential lock here necessary? The password is
+ * mutable but the contract could specify that this is not updated whilst
+ * a context is being initialized.
+ */
if (cred != GSS_C_NO_CREDENTIAL)
GSSEAP_MUTEX_LOCK(&cred->mutex);
if (GSS_ERROR(major))
goto cleanup;
- assert(ctx->cred != GSS_C_NO_CREDENTIAL);
+ GSSEAP_ASSERT(ctx->cred != GSS_C_NO_CREDENTIAL);
}
GSSEAP_MUTEX_LOCK(&ctx->cred->mutex);
- assert(ctx->cred->flags & CRED_FLAG_RESOLVED);
- assert(ctx->cred->flags & CRED_FLAG_INITIATE);
+ GSSEAP_ASSERT(ctx->cred->flags & CRED_FLAG_RESOLVED);
+ GSSEAP_ASSERT(ctx->cred->flags & CRED_FLAG_INITIATE);
if (initialContextToken) {
major = initBegin(minor, ctx, target_name, mech_type,
if (time_rec != NULL)
gssEapContextTime(&tmpMinor, ctx, time_rec);
- assert(CTX_IS_ESTABLISHED(ctx) || major == GSS_S_CONTINUE_NEEDED);
+ GSSEAP_ASSERT(CTX_IS_ESTABLISHED(ctx) || major == GSS_S_CONTINUE_NEEDED);
cleanup:
if (cred != GSS_C_NO_CREDENTIAL)
output_token->length = 0;
output_token->value = NULL;
- assert(ctx == GSS_C_NO_CONTEXT || ctx->mechanismUsed != GSS_C_NO_OID);
-
if (ctx == GSS_C_NO_CONTEXT) {
if (input_token != GSS_C_NO_BUFFER && input_token->length != 0) {
*minor = GSSEAP_WRONG_SIZE;