⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eap.c

📁 IEEE 802.11a/b/g 服务器端AP
💻 C
📖 第 1 页 / 共 4 页
字号:
void eap_sm_request_pin(struct eap_sm *sm){	eap_sm_request(sm, TYPE_PIN, NULL, 0);}/** * eap_sm_request_otp - Request one time password from user (ctrl_iface) * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @msg: Message to be displayed to the user when asking for OTP * @msg_len: Length of the user displayable message * * EAP methods can call this function to request open time password (OTP) for * the current network. The request will be sent to monitor programs through * the control interface. */void eap_sm_request_otp(struct eap_sm *sm, const char *msg, size_t msg_len){	eap_sm_request(sm, TYPE_OTP, msg, msg_len);}/** * eap_sm_request_passphrase - Request passphrase from user (ctrl_iface) * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * * EAP methods can call this function to request passphrase for a private key * for the current network. This is normally called when the passphrase is not * included in the network configuration. The request will be sent to monitor * programs through the control interface. */void eap_sm_request_passphrase(struct eap_sm *sm){	eap_sm_request(sm, TYPE_PASSPHRASE, NULL, 0);}/** * eap_sm_notify_ctrl_attached - Notification of attached monitor * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * * Notify EAP state machines that a monitor was attached to the control * interface to trigger re-sending of pending requests for user input. */void eap_sm_notify_ctrl_attached(struct eap_sm *sm){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return;	/* Re-send any pending requests for user data since a new control	 * interface was added. This handles cases where the EAP authentication	 * starts immediately after system startup when the user interface is	 * not yet running. */	if (config->pending_req_identity)		eap_sm_request_identity(sm);	if (config->pending_req_password)		eap_sm_request_password(sm);	if (config->pending_req_new_password)		eap_sm_request_new_password(sm);	if (config->pending_req_otp)		eap_sm_request_otp(sm, NULL, 0);	if (config->pending_req_pin)		eap_sm_request_pin(sm);	if (config->pending_req_passphrase)		eap_sm_request_passphrase(sm);}static int eap_allowed_phase2_type(int vendor, int type){	if (vendor != EAP_VENDOR_IETF)		return 0;	return type != EAP_TYPE_PEAP && type != EAP_TYPE_TTLS &&		type != EAP_TYPE_FAST;}/** * eap_get_phase2_type - Get EAP type for the given EAP phase 2 method name * @name: EAP method name, e.g., MD5 * @vendor: Buffer for returning EAP Vendor-Id * Returns: EAP method type or %EAP_TYPE_NONE if not found * * This function maps EAP type names into EAP type numbers that are allowed for * Phase 2, i.e., for tunneled authentication. Phase 2 is used, e.g., with * EAP-PEAP, EAP-TTLS, and EAP-FAST. */u32 eap_get_phase2_type(const char *name, int *vendor){	int v;	u8 type = eap_peer_get_type(name, &v);	if (eap_allowed_phase2_type(v, type)) {		*vendor = v;		return type;	}	*vendor = EAP_VENDOR_IETF;	return EAP_TYPE_NONE;}/** * eap_get_phase2_types - Get list of allowed EAP phase 2 types * @config: Pointer to a network configuration * @count: Pointer to a variable to be filled with number of returned EAP types * Returns: Pointer to allocated type list or %NULL on failure * * This function generates an array of allowed EAP phase 2 (tunneled) types for * the given network configuration. */struct eap_method_type * eap_get_phase2_types(struct eap_peer_config *config,					      size_t *count){	struct eap_method_type *buf;	u32 method;	int vendor;	size_t mcount;	const struct eap_method *methods, *m;	methods = eap_peer_get_methods(&mcount);	if (methods == NULL)		return NULL;	*count = 0;	buf = os_malloc(mcount * sizeof(struct eap_method_type));	if (buf == NULL)		return NULL;	for (m = methods; m; m = m->next) {		vendor = m->vendor;		method = m->method;		if (eap_allowed_phase2_type(vendor, method)) {			if (vendor == EAP_VENDOR_IETF &&			    method == EAP_TYPE_TLS && config &&			    config->private_key2 == NULL)				continue;			buf[*count].vendor = vendor;			buf[*count].method = method;			(*count)++;		}	}	return buf;}/** * eap_set_fast_reauth - Update fast_reauth setting * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @enabled: 1 = Fast reauthentication is enabled, 0 = Disabled */void eap_set_fast_reauth(struct eap_sm *sm, int enabled){	sm->fast_reauth = enabled;}/** * eap_set_workaround - Update EAP workarounds setting * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @workaround: 1 = Enable EAP workarounds, 0 = Disable EAP workarounds */void eap_set_workaround(struct eap_sm *sm, unsigned int workaround){	sm->workaround = workaround;}/** * eap_get_config - Get current network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * Returns: Pointer to the current network configuration or %NULL if not found * * EAP peer methods should avoid using this function if they can use other * access functions, like eap_get_config_identity() and * eap_get_config_password(), that do not require direct access to * struct eap_peer_config. */struct eap_peer_config * eap_get_config(struct eap_sm *sm){	return sm->eapol_cb->get_config(sm->eapol_ctx);}/** * eap_get_config_identity - Get identity from the network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @len: Buffer for the length of the identity * Returns: Pointer to the identity or %NULL if not found */const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return NULL;	*len = config->identity_len;	return config->identity;}/** * eap_get_config_password - Get password from the network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @len: Buffer for the length of the password * Returns: Pointer to the password or %NULL if not found */const u8 * eap_get_config_password(struct eap_sm *sm, size_t *len){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return NULL;	*len = config->password_len;	return config->password;}/** * eap_get_config_password2 - Get password from the network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @len: Buffer for the length of the password * @hash: Buffer for returning whether the password is stored as a * NtPasswordHash instead of plaintext password; can be %NULL if this * information is not needed * Returns: Pointer to the password or %NULL if not found */const u8 * eap_get_config_password2(struct eap_sm *sm, size_t *len, int *hash){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return NULL;	*len = config->password_len;	if (hash)		*hash = !!(config->flags & EAP_CONFIG_FLAGS_PASSWORD_NTHASH);	return config->password;}/** * eap_get_config_new_password - Get new password from network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @len: Buffer for the length of the new password * Returns: Pointer to the new password or %NULL if not found */const u8 * eap_get_config_new_password(struct eap_sm *sm, size_t *len){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return NULL;	*len = config->new_password_len;	return config->new_password;}/** * eap_get_config_otp - Get one-time password from the network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @len: Buffer for the length of the one-time password * Returns: Pointer to the one-time password or %NULL if not found */const u8 * eap_get_config_otp(struct eap_sm *sm, size_t *len){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return NULL;	*len = config->otp_len;	return config->otp;}/** * eap_clear_config_otp - Clear used one-time password * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * * This function clears a used one-time password (OTP) from the current network * configuration. This should be called when the OTP has been used and is not * needed anymore. */void eap_clear_config_otp(struct eap_sm *sm){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return;	os_memset(config->otp, 0, config->otp_len);	os_free(config->otp);	config->otp = NULL;	config->otp_len = 0;}/** * eap_get_config_phase1 - Get phase1 data from the network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * Returns: Pointer to the phase1 data or %NULL if not found */const char * eap_get_config_phase1(struct eap_sm *sm){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return NULL;	return config->phase1;}/** * eap_get_config_phase2 - Get phase2 data from the network configuration * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * Returns: Pointer to the phase1 data or %NULL if not found */const char * eap_get_config_phase2(struct eap_sm *sm){	struct eap_peer_config *config = eap_get_config(sm);	if (config == NULL)		return NULL;	return config->phase2;}/** * eap_key_available - Get key availability (eapKeyAvailable variable) * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * Returns: 1 if EAP keying material is available, 0 if not */int eap_key_available(struct eap_sm *sm){	return sm ? sm->eapKeyAvailable : 0;}/** * eap_notify_success - Notify EAP state machine about external success trigger * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * * This function is called when external event, e.g., successful completion of * WPA-PSK key handshake, is indicating that EAP state machine should move to * success state. This is mainly used with security modes that do not use EAP * state machine (e.g., WPA-PSK). */void eap_notify_success(struct eap_sm *sm){	if (sm) {		sm->decision = DECISION_COND_SUCC;		sm->EAP_state = EAP_SUCCESS;	}}/** * eap_notify_lower_layer_success - Notification of lower layer success * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * * Notify EAP state machines that a lower layer has detected a successful * authentication. This is used to recover from dropped EAP-Success messages. */void eap_notify_lower_layer_success(struct eap_sm *sm){	if (sm == NULL)		return;	if (eapol_get_bool(sm, EAPOL_eapSuccess) ||	    sm->decision == DECISION_FAIL ||	    (sm->methodState != METHOD_MAY_CONT &&	     sm->methodState != METHOD_DONE))		return;	if (sm->eapKeyData != NULL)		sm->eapKeyAvailable = TRUE;	eapol_set_bool(sm, EAPOL_eapSuccess, TRUE);	wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_SUCCESS		"EAP authentication completed successfully (based on lower "		"layer success)");}/** * eap_get_eapKeyData - Get master session key (MSK) from EAP state machine * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @len: Pointer to variable that will be set to number of bytes in the key * Returns: Pointer to the EAP keying data or %NULL on failure * * Fetch EAP keying material (MSK, eapKeyData) from the EAP state machine. The * key is available only after a successful authentication. EAP state machine * continues to manage the key data and the caller must not change or free the * returned data. */const u8 * eap_get_eapKeyData(struct eap_sm *sm, size_t *len){	if (sm == NULL || sm->eapKeyData == NULL) {		*len = 0;		return NULL;	}	*len = sm->eapKeyDataLen;	return sm->eapKeyData;}/** * eap_get_eapKeyData - Get EAP response data * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * Returns: Pointer to the EAP response (eapRespData) or %NULL on failure * * Fetch EAP response (eapRespData) from the EAP state machine. This data is * available when EAP state machine has processed an incoming EAP request. The * EAP state machine does not maintain a reference to the response after this * function is called and the caller is responsible for freeing the data. */struct wpabuf * eap_get_eapRespData(struct eap_sm *sm){	struct wpabuf *resp;	if (sm == NULL || sm->eapRespData == NULL)		return NULL;	resp = sm->eapRespData;	sm->eapRespData = NULL;	return resp;}/** * eap_sm_register_scard_ctx - Notification of smart card context * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @ctx: Context data for smart card operations * * Notify EAP state machines of context data for smart card operations. This * context data will be used as a parameter for scard_*() functions. */void eap_register_scard_ctx(struct eap_sm *sm, void *ctx){	if (sm)		sm->scard_ctx = ctx;}/** * eap_set_config_blob - Set or add a named configuration blob * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @blob: New value for the blob * * Adds a new configuration blob or replaces the current value of an existing * blob. */void eap_set_config_blob(struct eap_sm *sm, struct wpa_config_blob *blob){#ifndef CONFIG_NO_CONFIG_BLOBS	sm->eapol_cb->set_config_blob(sm->eapol_ctx, blob);#endif /* CONFIG_NO_CONFIG_BLOBS */}/** * eap_get_config_blob - Get a named configuration blob * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @name: Name of the blob * Returns: Pointer to blob data or %NULL if not found */const struct wpa_config_blob * eap_get_config_blob(struct eap_sm *sm,						   const char *name){#ifndef CONFIG_NO_CONFIG_BLOBS	return sm->eapol_cb->get_config_blob(sm->eapol_ctx, name);#else /* CONFIG_NO_CONFIG_BLOBS */	return NULL;#endif /* CONFIG_NO_CONFIG_BLOBS */}/** * eap_set_force_disabled - Set force_disabled flag * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @disabled: 1 = EAP disabled, 0 = EAP enabled * * This function is used to force EAP state machine to be disabled when it is * not in use (e.g., with WPA-PSK or plaintext connections). */void eap_set_force_disabled(struct eap_sm *sm, int disabled){	sm->force_disabled = disabled;} /** * eap_notify_pending - Notify that EAP method is ready to re-process a request * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * * An EAP method can perform a pending operation (e.g., to get a response from * an external process). Once the response is available, this function can be * used to request EAPOL state machine to retry delivering the previously * received (and still unanswered) EAP request to EAP state machine. */void eap_notify_pending(struct eap_sm *sm){	sm->eapol_cb->notify_pending(sm->eapol_ctx);}/** * eap_invalidate_cached_session - Mark cached session data invalid * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() */void eap_invalidate_cached_session(struct eap_sm *sm){	if (sm)		eap_deinit_prev_method(sm, "invalidate");}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -