Clean up EAP peer PCSC identity functions

Leave out more code if PCSC_FUNCS is not defined since config->pcsc != 0
case cannot be used with such a build.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2016-02-07 20:51:04 +02:00
parent b81e50cddb
commit 1314bc11cf

View File

@ -1386,13 +1386,10 @@ static int eap_sm_imsi_identity(struct eap_sm *sm,
return 0; return 0;
} }
#endif /* PCSC_FUNCS */
static int eap_sm_set_scard_pin(struct eap_sm *sm, static int eap_sm_set_scard_pin(struct eap_sm *sm,
struct eap_peer_config *conf) struct eap_peer_config *conf)
{ {
#ifdef PCSC_FUNCS
if (scard_set_pin(sm->scard_ctx, conf->pin)) { if (scard_set_pin(sm->scard_ctx, conf->pin)) {
/* /*
* Make sure the same PIN is not tried again in order to avoid * Make sure the same PIN is not tried again in order to avoid
@ -1406,24 +1403,20 @@ static int eap_sm_set_scard_pin(struct eap_sm *sm,
return -1; return -1;
} }
return 0; return 0;
#else /* PCSC_FUNCS */
return -1;
#endif /* PCSC_FUNCS */
} }
static int eap_sm_get_scard_identity(struct eap_sm *sm, static int eap_sm_get_scard_identity(struct eap_sm *sm,
struct eap_peer_config *conf) struct eap_peer_config *conf)
{ {
#ifdef PCSC_FUNCS
if (eap_sm_set_scard_pin(sm, conf)) if (eap_sm_set_scard_pin(sm, conf))
return -1; return -1;
return eap_sm_imsi_identity(sm, conf); return eap_sm_imsi_identity(sm, conf);
#else /* PCSC_FUNCS */
return -1;
#endif /* PCSC_FUNCS */
} }
#endif /* PCSC_FUNCS */
/** /**
* eap_sm_buildIdentity - Build EAP-Identity/Response for the current network * eap_sm_buildIdentity - Build EAP-Identity/Response for the current network
@ -1466,23 +1459,27 @@ struct wpabuf * eap_sm_buildIdentity(struct eap_sm *sm, int id, int encrypted)
identity, identity_len); identity, identity_len);
} }
if (identity == NULL) { if (config->pcsc) {
wpa_printf(MSG_WARNING, "EAP: buildIdentity: identity " #ifdef PCSC_FUNCS
"configuration was not available"); if (!identity) {
if (config->pcsc) {
if (eap_sm_get_scard_identity(sm, config) < 0) if (eap_sm_get_scard_identity(sm, config) < 0)
return NULL; return NULL;
identity = config->identity; identity = config->identity;
identity_len = config->identity_len; identity_len = config->identity_len;
wpa_hexdump_ascii(MSG_DEBUG, "permanent identity from " wpa_hexdump_ascii(MSG_DEBUG,
"IMSI", identity, identity_len); "permanent identity from IMSI",
} else { identity, identity_len);
eap_sm_request_identity(sm); } else if (eap_sm_set_scard_pin(sm, config) < 0) {
return NULL; return NULL;
} }
} else if (config->pcsc) { #else /* PCSC_FUNCS */
if (eap_sm_set_scard_pin(sm, config) < 0) return NULL;
return NULL; #endif /* PCSC_FUNCS */
} else if (!identity) {
wpa_printf(MSG_WARNING,
"EAP: buildIdentity: identity configuration was not available");
eap_sm_request_identity(sm);
return NULL;
} }
resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_IDENTITY, identity_len, resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_IDENTITY, identity_len,