diff --git a/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h b/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h index a3efd0b1ed6f..15e63f3ceb1e 100644 --- a/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h +++ b/umac/cmn_services/cmn_defs/inc/wlan_cmn_ieee80211.h @@ -525,35 +525,7 @@ struct wlan_rsn_ie_hdr { u8 version[2]; }; -#define WLAN_RSN_IE_MIN_LEN 2 - -#ifndef WLAN_SCAN_SECURITY_FILTER_V1 -/** - * struct wlan_rsn_ie: rsn ie info - * @ver: RSN ver - * @gp_cipher_suite: group cipher - * @pwise_cipher_count: number of pw cipher - * @pwise_cipher_suites: pair wise cipher list - * @akm_suite_count: Number of akm suite - * @akm_suites: akm suites list - * @cap: RSN capability - * @pmkid_count: number of PMKID - * @pmkid: PMKID list - * @mgmt_cipher_suite: management (11w) cipher suite - */ -struct wlan_rsn_ie { - uint16_t ver; - uint32_t gp_cipher_suite; - uint16_t pwise_cipher_count; - uint32_t pwise_cipher_suites[WLAN_MAX_CIPHER]; - uint16_t akm_suite_count; - uint32_t akm_suites[WLAN_MAX_CIPHER]; - uint16_t cap; - uint16_t pmkid_count; - uint8_t pmkid[MAX_PMKID][PMKID_LEN]; - uint32_t mgmt_cipher_suite; -}; -#endif +#define WLAN_RSN_IE_MIN_LEN 2 #define WLAN_WAPI_IE_MIN_LEN 20 /** @@ -570,27 +542,6 @@ struct wlan_wpa_ie_hdr { u8 version[2]; }; -#ifndef WLAN_SCAN_SECURITY_FILTER_V1 -/** - * struct wlan_wpa_ie: WPA ie info - * @ver: WPA ver - * @mc_cipher: multicast cipher - * @uc_cipher_count: number of unicast cipher - * @uc_ciphers: unicast cipher list - * @auth_suite_count: Number of akm suite - * @auth_suites: akm suites list - * @cap: WPA capability - */ -struct wlan_wpa_ie { - uint16_t ver; - uint32_t mc_cipher; - uint16_t uc_cipher_count; - uint32_t uc_ciphers[WLAN_MAX_CIPHER]; - uint16_t auth_suite_count; - uint32_t auth_suites[WLAN_MAX_CIPHER]; - uint16_t cap; -}; -#endif #define WAPI_VERSION 1 #define WLAN_WAPI_OUI 0x721400 @@ -599,25 +550,6 @@ struct wlan_wpa_ie { #define WLAN_WAI_CERT_OR_SMS4 0x01 #define WLAN_WAI_PSK 0x02 -#ifndef WLAN_SCAN_SECURITY_FILTER_V1 -/** - * struct wlan_wapi_ie: WAPI ie info - * @ver: WAPI ver - * @akm_suite_count: Number of akm suite - * @akm_suites: akm suites list - * @uc_cipher_suites:unicast cipher count - * @uc_cipher_suites: unicast cipher suite - * @mc_cipher_suite: mc cipher suite - */ -struct wlan_wapi_ie { - uint16_t ver; - uint16_t akm_suite_count; - uint32_t akm_suites[WLAN_MAX_CIPHER]; - uint16_t uc_cipher_count; - uint32_t uc_cipher_suites[WLAN_MAX_CIPHER]; - uint32_t mc_cipher_suite; -}; -#endif /** * struct wlan_frame_hdr: generic IEEE 802.11 frames * @i_fc: frame control @@ -1552,325 +1484,6 @@ is_sae_single_pmk_oui(uint8_t *frm) ((SAE_SINGLE_PMK_TYPE << OUI_TYPE_BITS) | SAE_SINGLE_PMK_OUI)); } -#ifndef WLAN_SCAN_SECURITY_FILTER_V1 -/** - * wlan_parse_rsn_ie() - parse rsn ie - * @rsn_ie: rsn ie ptr - * @rsn: out structure for the parsed ie - * - * API, function to parse rsn ie, if optional fields are not present use the - * default values defined by standard. - * - * Return: QDF_STATUS - */ -static inline QDF_STATUS wlan_parse_rsn_ie(uint8_t *rsn_ie, - struct wlan_rsn_ie *rsn) -{ - uint8_t rsn_ie_len, i; - uint8_t *ie; - int rem_len; - const struct wlan_rsn_ie_hdr *hdr; - - if (!rsn_ie) - return QDF_STATUS_E_NULL_VALUE; - - ie = rsn_ie; - rsn_ie_len = ie[1] + 2; - - /* - * Check the length once for fixed parts: - * element id, len and version. Other, variable-length data, - * must be checked separately. - */ - if (rsn_ie_len < sizeof(struct wlan_rsn_ie_hdr)) - return QDF_STATUS_E_INVAL; - - hdr = (struct wlan_rsn_ie_hdr *) rsn_ie; - - if (hdr->elem_id != WLAN_ELEMID_RSN || - LE_READ_2(hdr->version) != RSN_VERSION) - return QDF_STATUS_E_INVAL; - - /* Set default values for optional field. */ - rsn->gp_cipher_suite = WLAN_RSN_SEL(WLAN_CSE_CCMP); - rsn->pwise_cipher_count = 1; - rsn->pwise_cipher_suites[0] = WLAN_RSN_SEL(WLAN_CSE_CCMP); - rsn->akm_suite_count = 1; - rsn->akm_suites[0] = WLAN_RSN_SEL(WLAN_AKM_IEEE8021X); - - rsn->ver = LE_READ_2(hdr->version); - - ie = (uint8_t *) (hdr + 1); - rem_len = rsn_ie_len - sizeof(*hdr); - - /* Check if optional group cipher is present */ - if (rem_len >= WLAN_RSN_SELECTOR_LEN) { - rsn->gp_cipher_suite = LE_READ_4(ie); - ie += WLAN_RSN_SELECTOR_LEN; - rem_len -= WLAN_RSN_SELECTOR_LEN; - } else if (rem_len > 0) { - /* RSN IE is invalid as group cipher is of invalid length */ - return QDF_STATUS_E_INVAL; - } - - /* Check if optional pairwise cipher is present */ - if (rem_len >= 2) { - rsn->pwise_cipher_count = LE_READ_2(ie); - ie += 2; - rem_len -= 2; - if (rsn->pwise_cipher_count == 0 || - rsn->pwise_cipher_count > WLAN_MAX_CIPHER || - rsn->pwise_cipher_count > rem_len / WLAN_RSN_SELECTOR_LEN) - return QDF_STATUS_E_INVAL; - for (i = 0; i < rsn->pwise_cipher_count; i++) { - rsn->pwise_cipher_suites[i] = LE_READ_4(ie); - ie += WLAN_RSN_SELECTOR_LEN; - rem_len -= WLAN_RSN_SELECTOR_LEN; - } - } else if (rem_len == 1) { - /* RSN IE is invalid as pairwise cipher is of invalid length */ - return QDF_STATUS_E_INVAL; - } - - /* Check if optional akm suite is present */ - if (rem_len >= 2) { - rsn->akm_suite_count = LE_READ_2(ie); - ie += 2; - rem_len -= 2; - if (rsn->akm_suite_count == 0 || - rsn->akm_suite_count > WLAN_MAX_CIPHER || - rsn->akm_suite_count > rem_len / WLAN_RSN_SELECTOR_LEN) - return QDF_STATUS_E_INVAL; - for (i = 0; i < rsn->akm_suite_count; i++) { - rsn->akm_suites[i] = LE_READ_4(ie); - ie += WLAN_RSN_SELECTOR_LEN; - rem_len -= WLAN_RSN_SELECTOR_LEN; - } - } else if (rem_len == 1) { - /* RSN IE is invalid as akm suite is of invalid length */ - return QDF_STATUS_E_INVAL; - } - - /* Update capabilty if present */ - if (rem_len >= 2) { - rsn->cap = LE_READ_2(ie); - ie += 2; - rem_len -= 2; - } else if (rem_len == 1) { - /* RSN IE is invalid as cap field is truncated */ - return QDF_STATUS_E_INVAL; - } - - /* Update PMKID if present */ - if (rem_len >= 2) { - rsn->pmkid_count = LE_READ_2(ie); - ie += 2; - rem_len -= 2; - if (rsn->pmkid_count > MAX_PMKID || - rsn->pmkid_count > (unsigned int)rem_len / PMKID_LEN) { - rsn->pmkid_count = 0; - return QDF_STATUS_E_INVAL; - } - - qdf_mem_copy(rsn->pmkid, ie, - rsn->pmkid_count * PMKID_LEN); - ie += rsn->pmkid_count * PMKID_LEN; - rem_len -= rsn->pmkid_count * PMKID_LEN; - } else if (rem_len == 1) { - /* RSN IE is invalid as pmkid count field is truncated */ - return QDF_STATUS_E_INVAL; - } - - /* Update mgmt cipher if present */ - if (rem_len >= WLAN_RSN_SELECTOR_LEN) { - rsn->mgmt_cipher_suite = LE_READ_4(ie); - ie += WLAN_RSN_SELECTOR_LEN; - rem_len -= WLAN_RSN_SELECTOR_LEN; - } else if (rem_len > 0) { - /* RSN IE is invalid as mgmt cipher is truncated */ - return QDF_STATUS_E_INVAL; - } - - return QDF_STATUS_SUCCESS; -} - -/** - * wlan_parse_wpa_ie() - parse wpa ie - * @wpa_ie: wpa ie ptr - * @wpa: out structure for the parsed ie - * - * API, function to parse wpa ie, if optional fields are not present use the - * default values defined by standard. - * - * Return: QDF_STATUS - */ -static inline QDF_STATUS wlan_parse_wpa_ie(uint8_t *wpa_ie, - struct wlan_wpa_ie *wpa) -{ - uint8_t wpa_ie_len, i; - uint8_t *ie; - int rem_len; - struct wlan_wpa_ie_hdr *hdr; - - if (!wpa_ie) - return QDF_STATUS_E_NULL_VALUE; - - ie = wpa_ie; - wpa_ie_len = ie[1] + 2; - - /* - * Check the length once for fixed parts: - * element id, len, oui and version. Other, variable-length data, - * must be checked separately. - */ - if (wpa_ie_len < sizeof(struct wlan_wpa_ie_hdr)) - return QDF_STATUS_E_INVAL; - - hdr = (struct wlan_wpa_ie_hdr *) wpa_ie; - - if (hdr->elem_id != WLAN_ELEMID_VENDOR || - !is_wpa_oui(wpa_ie) || - LE_READ_2(hdr->version) != WPA_VERSION) - return QDF_STATUS_E_INVAL; - - /* Set default values for optional field. */ - wpa->mc_cipher = WLAN_WPA_SEL(WLAN_CSE_TKIP); - wpa->uc_cipher_count = 1; - wpa->uc_ciphers[0] = WLAN_WPA_SEL(WLAN_CSE_TKIP); - wpa->auth_suite_count = 1; - wpa->auth_suites[0] = WLAN_WPA_SEL(WLAN_ASE_8021X_UNSPEC); - - wpa->ver = LE_READ_2(hdr->version); - ie = (uint8_t *) (hdr + 1); - rem_len = wpa_ie_len - sizeof(*hdr); - - /* Check if optional group cipher is present */ - if (rem_len >= WLAN_WPA_SELECTOR_LEN) { - wpa->mc_cipher = LE_READ_4(ie); - ie += WLAN_WPA_SELECTOR_LEN; - rem_len -= WLAN_WPA_SELECTOR_LEN; - } else if (rem_len > 0) { - /* WPA IE is invalid as group cipher is of invalid length */ - return QDF_STATUS_E_INVAL; - } - - /* Check if optional pairwise cipher is present */ - if (rem_len >= 2) { - wpa->uc_cipher_count = LE_READ_2(ie); - ie += 2; - rem_len -= 2; - if (wpa->uc_cipher_count == 0 || - wpa->uc_cipher_count > WLAN_MAX_CIPHER || - wpa->uc_cipher_count > rem_len / WLAN_WPA_SELECTOR_LEN) - return QDF_STATUS_E_INVAL; - for (i = 0; i < wpa->uc_cipher_count; i++) { - wpa->uc_ciphers[i] = LE_READ_4(ie); - ie += WLAN_WPA_SELECTOR_LEN; - rem_len -= WLAN_WPA_SELECTOR_LEN; - } - } else if (rem_len == 1) { - /* WPA IE is invalid as pairwise cipher is of invalid length */ - return QDF_STATUS_E_INVAL; - } - - /* Check if optional akm suite is present */ - if (rem_len >= 2) { - wpa->auth_suite_count = LE_READ_2(ie); - ie += 2; - rem_len -= 2; - if (wpa->auth_suite_count == 0 || - wpa->auth_suite_count > WLAN_MAX_CIPHER || - wpa->auth_suite_count > rem_len / WLAN_WPA_SELECTOR_LEN) - return QDF_STATUS_E_INVAL; - for (i = 0; i < wpa->auth_suite_count; i++) { - wpa->auth_suites[i] = LE_READ_4(ie); - ie += WLAN_WPA_SELECTOR_LEN; - rem_len -= WLAN_WPA_SELECTOR_LEN; - } - } else if (rem_len == 1) { - /* WPA IE is invalid as akm suite is of invalid length */ - return QDF_STATUS_E_INVAL; - } - - /* Update capabilty if optional capabilty is present */ - if (rem_len >= 2) { - wpa->cap = LE_READ_2(ie); - ie += 2; - rem_len -= 2; - } - - return QDF_STATUS_SUCCESS; -} - -/** - * wlan_parse_wapi_ie() - parse wapi ie - * @wapi_ie: wpa ie ptr - * @wapi: out structure for the parsed IE - * - * API, function to parse wapi ie - * - * Return: void - */ -static inline void wlan_parse_wapi_ie(uint8_t *wapi_ie, - struct wlan_wapi_ie *wapi) -{ - uint8_t len, i; - uint8_t *ie; - - if (!wapi_ie) - return; - - ie = wapi_ie; - len = ie[1]; - /* - * Check the length once for fixed parts: OUI, type, - * version, mcast cipher, and 2 selector counts. - * Other, variable-length data, must be checked separately. - */ - if (len < 20) - return; - - ie += 2; - - wapi->ver = LE_READ_2(ie); - if (wapi->ver != WAPI_VERSION) - return; - - ie += 2; - len -= 2; - - /* akm */ - wapi->akm_suite_count = LE_READ_2(ie); - - ie += 2; - len -= 2; - - if ((wapi->akm_suite_count > WLAN_MAX_CIPHER) || - len < (wapi->akm_suite_count * WLAN_OUI_SIZE)) - return; - for (i = 0 ; i < wapi->akm_suite_count; i++) { - wapi->akm_suites[i] = LE_READ_4(ie); - ie += WLAN_OUI_SIZE; - len -= WLAN_OUI_SIZE; - } - - wapi->uc_cipher_count = LE_READ_2(ie); - ie += 2; - len -= 2; - if ((wapi->uc_cipher_count > WLAN_MAX_CIPHER) || - len < (wapi->uc_cipher_count * WLAN_OUI_SIZE + 2)) - return; - for (i = 0 ; i < wapi->uc_cipher_count; i++) { - wapi->uc_cipher_suites[i] = LE_READ_4(ie); - ie += WLAN_OUI_SIZE; - len -= WLAN_OUI_SIZE; - } - - if (len >= WLAN_OUI_SIZE) - wapi->mc_cipher_suite = LE_READ_4(ie); -} -#endif - /** * wlan_parse_oce_reduced_wan_metrics_ie() - parse oce wan metrics * @mbo_oce_ie: MBO/OCE ie ptr diff --git a/umac/cmn_services/inc/wlan_cmn.h b/umac/cmn_services/inc/wlan_cmn.h index e01d3364b97d..06c0f91993e2 100644 --- a/umac/cmn_services/inc/wlan_cmn.h +++ b/umac/cmn_services/inc/wlan_cmn.h @@ -572,107 +572,6 @@ enum wlan_pmf_cap { WLAN_PMF_REQUIRED, }; -#ifndef WLAN_SCAN_SECURITY_FILTER_V1 -/** - * enum wlan_auth_type - Enumeration of the various Auth types - * @WLAN_AUTH_TYPE_OPEN_SYSTEM: Open auth type - * @WLAN_AUTH_TYPE_SHARED_KEY: Shared Key Auth type - * @WLAN_AUTH_TYPE_AUTOSWITCH: Auto switch Open/Shared - * @WLAN_AUTH_TYPE_SAE: SAE auth type - * @WLAN_AUTH_TYPE_WPA: WPA Enterprise - * @WLAN_AUTH_TYPE_WPA_PSK: WPA PSK - * @WLAN_AUTH_TYPE_WPA_NONE: WPA None - * @WLAN_AUTH_TYPE_RSN: RSN Enterprise - * @WLAN_AUTH_TYPE_RSN_PSK: RSN PSK - * @WLAN_AUTH_TYPE_FT_RSN: FT RSN Enterprise - * @WLAN_AUTH_TYPE_FT_RSN_PSK: FT RSN PSK - * @WLAN_AUTH_TYPE_WAPI_WAI_CERTIFICATE: WAPI certificate - * @WLAN_AUTH_TYPE_WAPI_WAI_PSK: WAPI PSK - * @WLAN_AUTH_TYPE_CCKM_WPA: CCKM WPA - * @WLAN_AUTH_TYPE_CCKM_RSN: CCKM RSN - * @WLAN_AUTH_TYPE_RSN_PSK_SHA256: SHA256 PSK - * @WLAN_AUTH_TYPE_RSN_8021X_SHA256: SHA256 Enterprise - * @WLAN_AUTH_TYPE_FILS_SHA256: FILS SHA256 - * @WLAN_AUTH_TYPE_FILS_SHA384: FILS SHA384 - * @WLAN_AUTH_TYPE_FT_FILS_SHA256: FILS SHA256 for 11r - * @WLAN_AUTH_TYPE_FT_FILS_SHA384: FILS SHA384 for 11r - * @WLAN_AUTH_TYPE_DPP_RSN: DPP RSN - * @WLAN_AUTH_TYPE_OWE: OWE - * @WLAN_AUTH_TYPE_SUITEB_EAP_SHA256: EAP SHA256 - * @WLAN_AUTH_TYPE_SUITEB_EAP_SHA384: EAP SHA384 - * @WLAN_AUTH_TYPE_FT_SAE: FT SAE - * @WLAN_AUTH_TYPE_FT_SUITEB_EAP_SHA384: FT suiteb SHA384 - * @WLAN_AUTH_TYPE_ANY: To match any auth type - * @WLAN_NUM_OF_SUPPORT_AUTH_TYPE: Max no of Auth type - */ -enum wlan_auth_type { - WLAN_AUTH_TYPE_OPEN_SYSTEM, - WLAN_AUTH_TYPE_SHARED_KEY, - WLAN_AUTH_TYPE_AUTOSWITCH, - WLAN_AUTH_TYPE_SAE, - WLAN_AUTH_TYPE_WPA, - WLAN_AUTH_TYPE_WPA_PSK, - WLAN_AUTH_TYPE_WPA_NONE, - WLAN_AUTH_TYPE_RSN, - WLAN_AUTH_TYPE_RSN_PSK, - WLAN_AUTH_TYPE_FT_RSN, - WLAN_AUTH_TYPE_FT_RSN_PSK, - WLAN_AUTH_TYPE_WAPI_WAI_CERTIFICATE, - WLAN_AUTH_TYPE_WAPI_WAI_PSK, - WLAN_AUTH_TYPE_CCKM_WPA, - WLAN_AUTH_TYPE_CCKM_RSN, - WLAN_AUTH_TYPE_RSN_PSK_SHA256, - WLAN_AUTH_TYPE_RSN_8021X_SHA256, - WLAN_AUTH_TYPE_FILS_SHA256, - WLAN_AUTH_TYPE_FILS_SHA384, - WLAN_AUTH_TYPE_FT_FILS_SHA256, - WLAN_AUTH_TYPE_FT_FILS_SHA384, - WLAN_AUTH_TYPE_DPP_RSN, - WLAN_AUTH_TYPE_OWE, - WLAN_AUTH_TYPE_SUITEB_EAP_SHA256, - WLAN_AUTH_TYPE_SUITEB_EAP_SHA384, - WLAN_AUTH_TYPE_OSEN, - WLAN_AUTH_TYPE_FT_SAE, - WLAN_AUTH_TYPE_FT_SUITEB_EAP_SHA384, - WLAN_AUTH_TYPE_ANY, - WLAN_NUM_OF_SUPPORT_AUTH_TYPE = WLAN_AUTH_TYPE_ANY, -}; - -/** - * enum wlan_enc_type - Enumeration of the various Enc types - * @WLAN_ENCRYPT_TYPE_NONE: No encryption - * @WLAN_ENCRYPT_TYPE_WEP40_STATICKEY: WEP 40 Static key - * @WLAN_ENCRYPT_TYPE_WEP104_STATICKEY: WEP 104 Static key - * @WLAN_ENCRYPT_TYPE_WEP40: WEP 40 - * @WLAN_ENCRYPT_TYPE_WEP104: WEP 104 - * @WLAN_ENCRYPT_TYPE_TKIP: TKIP - * @WLAN_ENCRYPT_TYPE_AES: AES - * @WLAN_ENCRYPT_TYPE_WPI: WAPI - * @WLAN_ENCRYPT_TYPE_KRK: KRK - * @WLAN_ENCRYPT_TYPE_BTK: BTK - * @WLAN_ENCRYPT_TYPE_AES_CMAC: 11W BIP - * @WLAN_ENCRYPT_TYPE_ANY: Any - * @WLAN_NUM_OF_ENCRYPT_TYPE: Max value - */ -enum wlan_enc_type { - WLAN_ENCRYPT_TYPE_NONE, - WLAN_ENCRYPT_TYPE_WEP40_STATICKEY, - WLAN_ENCRYPT_TYPE_WEP104_STATICKEY, - WLAN_ENCRYPT_TYPE_WEP40, - WLAN_ENCRYPT_TYPE_WEP104, - WLAN_ENCRYPT_TYPE_TKIP, - WLAN_ENCRYPT_TYPE_AES, - WLAN_ENCRYPT_TYPE_WPI, - WLAN_ENCRYPT_TYPE_KRK, - WLAN_ENCRYPT_TYPE_BTK, - WLAN_ENCRYPT_TYPE_AES_CMAC, - WLAN_ENCRYPT_TYPE_AES_GCMP, - WLAN_ENCRYPT_TYPE_AES_GCMP_256, - WLAN_ENCRYPT_TYPE_ANY, - WLAN_NUM_OF_ENCRYPT_TYPE = WLAN_ENCRYPT_TYPE_ANY, -}; -#endif - /** * struct wlan_ssid - SSID info * @length: ssid length of bss excluding null diff --git a/umac/scan/core/src/wlan_scan_filter.c b/umac/scan/core/src/wlan_scan_filter.c index 981da80a750c..2e166b0d6f2e 100644 --- a/umac/scan/core/src/wlan_scan_filter.c +++ b/umac/scan/core/src/wlan_scan_filter.c @@ -22,8 +22,6 @@ #include #include "wlan_scan_main.h" #include "wlan_scan_cache_db_i.h" - -#ifdef WLAN_SCAN_SECURITY_FILTER_V1 #include "wlan_crypto_global_def.h" #include "wlan_crypto_global_api.h" @@ -529,1092 +527,6 @@ static bool scm_ignore_ssid_check_for_owe(struct scan_filter *filter, return false; } -#else - -/** - * scm_is_open_security() - Check if scan entry support open security - * @filter: scan filter - * @db_entry: db entry - * @security: matched security. - * - * Return: true if open security else false - */ -static bool scm_is_open_security(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct security_info *security) -{ - bool match = false; - int i; - - if (db_entry->cap_info.wlan_caps.privacy) - return false; - - /* Check MC cipher and Auth type requested. */ - for (i = 0; i < filter->num_of_mc_enc_type; i++) { - if (WLAN_ENCRYPT_TYPE_NONE == - filter->mc_enc_type[i]) { - security->mc_enc = - filter->mc_enc_type[i]; - match = true; - break; - } - } - if (!match && filter->num_of_mc_enc_type) - return match; - - match = false; - /* Check Auth list. It should contain AuthOpen. */ - for (i = 0; i < filter->num_of_auth; i++) { - if ((WLAN_AUTH_TYPE_OPEN_SYSTEM == - filter->auth_type[i]) || - (WLAN_AUTH_TYPE_AUTOSWITCH == - filter->auth_type[i])) { - security->auth_type = - WLAN_AUTH_TYPE_OPEN_SYSTEM; - match = true; - break; - } - } - - return match; -} - -/** - * scm_is_cipher_match() - Check if cipher match the cipher list - * @cipher_list: cipher list to match - * @num_cipher: number of cipher in cipher list - * @cipher_to_match: cipher to found in cipher list - * - * Return: true if open security else false - */ -static bool scm_is_cipher_match( - uint32_t *cipher_list, - uint16_t num_cipher, uint32_t cipher_to_match) -{ - int i; - bool match = false; - - for (i = 0; i < num_cipher ; i++) { - match = (cipher_list[i] == cipher_to_match); - if (match) - break; - } - - return match; -} - -/** - * scm_get_cipher_suite_type() - get cypher suite type from enc type - * @enc: enc type - * - * Return: cypher suite type - */ -static uint8_t scm_get_cipher_suite_type(enum wlan_enc_type enc) -{ - uint8_t cipher_type; - - switch (enc) { - case WLAN_ENCRYPT_TYPE_WEP40: - case WLAN_ENCRYPT_TYPE_WEP40_STATICKEY: - cipher_type = WLAN_CSE_WEP40; - break; - case WLAN_ENCRYPT_TYPE_WEP104: - case WLAN_ENCRYPT_TYPE_WEP104_STATICKEY: - cipher_type = WLAN_CSE_WEP104; - break; - case WLAN_ENCRYPT_TYPE_TKIP: - cipher_type = WLAN_CSE_TKIP; - break; - case WLAN_ENCRYPT_TYPE_AES: - cipher_type = WLAN_CSE_CCMP; - break; - case WLAN_ENCRYPT_TYPE_AES_GCMP: - cipher_type = WLAN_CSE_GCMP_128; - break; - case WLAN_ENCRYPT_TYPE_AES_GCMP_256: - cipher_type = WLAN_CSE_GCMP_256; - break; - case WLAN_ENCRYPT_TYPE_NONE: - cipher_type = WLAN_CSE_NONE; - break; - case WLAN_ENCRYPT_TYPE_WPI: - cipher_type = WLAN_WAI_CERT_OR_SMS4; - break; - default: - cipher_type = WLAN_CSE_RESERVED; - break; - } - - return cipher_type; -} - -/** - * scm_is_wep_security() - Check if scan entry support WEP security - * @filter: scan filter - * @db_entry: db entry - * @security: matched security. - * - * Return: true if WEP security else false - */ -static bool scm_is_wep_security(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct security_info *security) -{ - int i; - QDF_STATUS status; - bool match = false; - enum wlan_auth_type neg_auth = WLAN_AUTH_TYPE_OPEN_SYSTEM; - enum wlan_enc_type neg_mccipher = WLAN_ENCRYPT_TYPE_NONE; - - if (!security) - return false; - - /* If privacy bit is not set, consider no match */ - if (!db_entry->cap_info.wlan_caps.privacy) - return false; - - for (i = 0; i < filter->num_of_mc_enc_type; i++) { - switch (filter->mc_enc_type[i]) { - case WLAN_ENCRYPT_TYPE_WEP40_STATICKEY: - case WLAN_ENCRYPT_TYPE_WEP104_STATICKEY: - case WLAN_ENCRYPT_TYPE_WEP40: - case WLAN_ENCRYPT_TYPE_WEP104: - /* - * Multicast list may contain WEP40/WEP104. - * Check whether it matches UC. - */ - if (security->uc_enc == - filter->mc_enc_type[i]) { - match = true; - neg_mccipher = - filter->mc_enc_type[i]; - } - break; - default: - match = false; - break; - } - if (match) - break; - } - - if (!match) - return match; - - for (i = 0; i < filter->num_of_auth; i++) { - switch (filter->auth_type[i]) { - case WLAN_AUTH_TYPE_OPEN_SYSTEM: - case WLAN_AUTH_TYPE_SHARED_KEY: - case WLAN_AUTH_TYPE_AUTOSWITCH: - match = true; - neg_auth = filter->auth_type[i]; - break; - default: - match = false; - } - if (match) - break; - } - - if (!match) - return match; - - /* - * In case of WPA / WPA2, check whether it supports WEP as well. - * Prepare the encryption type for WPA/WPA2 functions - */ - if (security->uc_enc == WLAN_ENCRYPT_TYPE_WEP40_STATICKEY) - security->uc_enc = WLAN_ENCRYPT_TYPE_WEP40; - else if (security->uc_enc == WLAN_ENCRYPT_TYPE_WEP104) - security->uc_enc = WLAN_ENCRYPT_TYPE_WEP104; - - /* else we can use the encryption type directly */ - if (util_scan_entry_wpa(db_entry)) { - struct wlan_wpa_ie wpa = {0}; - uint8_t cipher_type; - - cipher_type = - scm_get_cipher_suite_type(security->uc_enc); - status = wlan_parse_wpa_ie(util_scan_entry_wpa(db_entry), &wpa); - if (QDF_IS_STATUS_ERROR(status)) { - scm_err("failed to parse WPA IE, status %d", status); - scm_hex_dump(QDF_TRACE_LEVEL_DEBUG, - util_scan_entry_wpa(db_entry), - util_scan_get_wpa_len(db_entry)); - return false; - } - - match = scm_is_cipher_match(&wpa.mc_cipher, - 1, WLAN_WPA_SEL(cipher_type)); - } - if (!match && util_scan_entry_rsn(db_entry)) { - struct wlan_rsn_ie rsn = {0}; - uint8_t cipher_type; - - cipher_type = - scm_get_cipher_suite_type(security->uc_enc); - status = wlan_parse_rsn_ie(util_scan_entry_rsn(db_entry), &rsn); - if (QDF_IS_STATUS_ERROR(status)) { - scm_err("failed to parse RSN IE, status %d", status); - scm_hex_dump(QDF_TRACE_LEVEL_DEBUG, - util_scan_entry_rsn(db_entry), - util_scan_get_rsn_len(db_entry)); - return false; - } - match = scm_is_cipher_match(&rsn.gp_cipher_suite, - 1, WLAN_RSN_SEL(cipher_type)); - } - - - if (match) { - security->auth_type = neg_auth; - security->mc_enc = neg_mccipher; - } - - return match; -} - -/** - * scm_check_pmf_match() - Check PMF security of entry match filter - * @filter: scan filter - * @db_entry: ap entry - * @rsn: rsn IE of the scan entry - * - * Return: true if PMF security match else false - */ -static bool -scm_check_pmf_match(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct wlan_rsn_ie *rsn) -{ - enum wlan_pmf_cap ap_pmf_cap = WLAN_PMF_DISABLED; - bool match = true; - - if (rsn->cap & RSN_CAP_MFP_CAPABLE) - ap_pmf_cap = WLAN_PMF_CAPABLE; - if (rsn->cap & RSN_CAP_MFP_REQUIRED) - ap_pmf_cap = WLAN_PMF_REQUIRED; - - if ((filter->pmf_cap == WLAN_PMF_REQUIRED) && - (ap_pmf_cap == WLAN_PMF_DISABLED)) - match = false; - else if ((filter->pmf_cap == WLAN_PMF_DISABLED) && - (ap_pmf_cap == WLAN_PMF_REQUIRED)) - match = false; - - if (!match) - scm_debug("%pM : PMF cap didn't match (filter %d AP %d)", - db_entry->bssid.bytes, filter->pmf_cap, - ap_pmf_cap); - - return match; -} - -/** - * scm_is_rsn_mcast_cipher_match() - match the rsn mcast cipher type with AP's - * mcast cipher - * @rsn: AP's RSNE - * @filter: scan filter - * @neg_mccipher: negotiated mc cipher if matched. - * - * Return: true if mc cipher is negotiated - */ -static bool -scm_is_rsn_mcast_cipher_match(struct wlan_rsn_ie *rsn, - struct scan_filter *filter, enum wlan_enc_type *neg_mccipher) -{ - int i; - bool match; - uint8_t cipher_type; - - if (!rsn || !neg_mccipher || !filter) - return false; - - for (i = 0; i < filter->num_of_mc_enc_type; i++) { - - if (filter->mc_enc_type[i] == WLAN_ENCRYPT_TYPE_ANY) { - /* Try the more secured ones first. */ - /* Check GCMP_256 first */ - cipher_type = WLAN_CSE_GCMP_256; - match = scm_is_cipher_match(&rsn->gp_cipher_suite, 1, - WLAN_RSN_SEL(cipher_type)); - if (match) { - *neg_mccipher = WLAN_ENCRYPT_TYPE_AES_GCMP_256; - return true; - } - /* Check GCMP */ - cipher_type = WLAN_CSE_GCMP_128; - match = scm_is_cipher_match(&rsn->gp_cipher_suite, 1, - WLAN_RSN_SEL(cipher_type)); - if (match) { - *neg_mccipher = WLAN_ENCRYPT_TYPE_AES_GCMP; - return true; - } - /* Check AES */ - cipher_type = WLAN_CSE_CCMP; - match = scm_is_cipher_match(&rsn->gp_cipher_suite, 1, - WLAN_RSN_SEL(cipher_type)); - if (match) { - *neg_mccipher = WLAN_ENCRYPT_TYPE_AES; - return true; - } - /* Check TKIP */ - cipher_type = WLAN_CSE_TKIP; - match = scm_is_cipher_match(&rsn->gp_cipher_suite, 1, - WLAN_RSN_SEL(cipher_type)); - if (match) { - *neg_mccipher = WLAN_ENCRYPT_TYPE_TKIP; - return true; - } - } else { - cipher_type = - scm_get_cipher_suite_type(filter->mc_enc_type[i]); - match = scm_is_cipher_match(&rsn->gp_cipher_suite, 1, - WLAN_RSN_SEL(cipher_type)); - if (match) { - *neg_mccipher = filter->mc_enc_type[i]; - return true; - } - } - } - - return false; -} - -/** - * scm_is_rsn_security() - Check if scan entry support RSN security - * @filter: scan filter - * @db_entry: db entry - * @security: matched security. - * - * Return: true if RSN security else false - */ -static bool scm_is_rsn_security(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct security_info *security) -{ - int i; - uint8_t cipher_type; - bool match_any_akm, match = false; - enum wlan_auth_type neg_auth = WLAN_NUM_OF_SUPPORT_AUTH_TYPE; - enum wlan_auth_type filter_akm; - enum wlan_enc_type neg_mccipher = WLAN_ENCRYPT_TYPE_NONE; - struct wlan_rsn_ie rsn = {0}; - QDF_STATUS status; - bool is_adaptive_11r; - - if (!security) - return false; - if (!util_scan_entry_rsn(db_entry)) { - scm_debug("%pM : doesn't have RSN IE", db_entry->bssid.bytes); - return false; - } - status = wlan_parse_rsn_ie(util_scan_entry_rsn(db_entry), &rsn); - if (QDF_IS_STATUS_ERROR(status)) { - scm_err("failed to parse RSN IE, status %d", status); - scm_hex_dump(QDF_TRACE_LEVEL_DEBUG, - util_scan_entry_rsn(db_entry), - util_scan_get_rsn_len(db_entry)); - return false; - } - - cipher_type = - scm_get_cipher_suite_type(security->uc_enc); - match = scm_is_cipher_match(rsn.pwise_cipher_suites, - rsn.pwise_cipher_count, WLAN_RSN_SEL(cipher_type)); - if (!match) { - scm_debug("%pM : pairwise cipher didn't match", - db_entry->bssid.bytes); - return false; - } - - match = scm_is_rsn_mcast_cipher_match(&rsn, filter, &neg_mccipher); - if (!match) { - scm_debug("%pM : mcast cipher didn't match", - db_entry->bssid.bytes); - return false; - } - - is_adaptive_11r = (db_entry->adaptive_11r_ap && - filter->enable_adaptive_11r); - - /* Initializing with false as it has true value already */ - match = false; - for (i = 0; i < filter->num_of_auth; i++) { - - filter_akm = filter->auth_type[i]; - if (filter_akm == WLAN_AUTH_TYPE_ANY) - match_any_akm = true; - else - match_any_akm = false; - /* - * Ciphers are supported, Match authentication algorithm and - * pick first matching authtype. - */ - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_FILS_FT_SHA384))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_FT_FILS_SHA384)) { - neg_auth = WLAN_AUTH_TYPE_FT_FILS_SHA384; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_FILS_FT_SHA256))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_FT_FILS_SHA256)) { - neg_auth = WLAN_AUTH_TYPE_FT_FILS_SHA256; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_FILS_SHA384))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_FILS_SHA384)) { - neg_auth = WLAN_AUTH_TYPE_FILS_SHA384; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_FILS_SHA256))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_FILS_SHA256)) { - neg_auth = WLAN_AUTH_TYPE_FILS_SHA256; - match = true; - break; - } - } - - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_SAE))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_SAE)) { - neg_auth = WLAN_AUTH_TYPE_SAE; - match = true; - break; - } - } - - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, WLAN_RSN_DPP_AKM)) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_DPP_RSN)) { - neg_auth = WLAN_AUTH_TYPE_DPP_RSN; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_OSEN_AKM)) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_OSEN)) { - neg_auth = WLAN_AUTH_TYPE_OSEN; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_OWE))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_OWE)) { - neg_auth = WLAN_AUTH_TYPE_OWE; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_FT_IEEE8021X))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_FT_RSN)) { - neg_auth = WLAN_AUTH_TYPE_FT_RSN; - match = true; - break; - } - } - - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_FT_PSK))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_FT_RSN_PSK)) { - neg_auth = WLAN_AUTH_TYPE_FT_RSN_PSK; - match = true; - break; - } - } - /* ESE only supports 802.1X. No PSK. */ - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_CCKM_AKM)) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_CCKM_RSN)) { - neg_auth = WLAN_AUTH_TYPE_CCKM_RSN; - match = true; - break; - } - } - /* RSN */ - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_IEEE8021X))) { - if (is_adaptive_11r && - (filter_akm == WLAN_AUTH_TYPE_FT_RSN)) { - neg_auth = WLAN_AUTH_TYPE_FT_RSN; - match = true; - break; - } - - if (match_any_akm || - (WLAN_AUTH_TYPE_RSN == filter_akm)) { - neg_auth = WLAN_AUTH_TYPE_RSN; - match = true; - break; - } - } - /* TKIP */ - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_PSK))) { - if (is_adaptive_11r && - (filter_akm == WLAN_AUTH_TYPE_FT_RSN_PSK)) { - neg_auth = WLAN_AUTH_TYPE_FT_RSN_PSK; - match = true; - break; - } - - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_RSN_PSK)) { - neg_auth = WLAN_AUTH_TYPE_RSN_PSK; - match = true; - break; - } - } - /* SHA256 */ - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_SHA256_PSK))) { - if (is_adaptive_11r && - (filter_akm == WLAN_AUTH_TYPE_FT_RSN_PSK)) { - neg_auth = WLAN_AUTH_TYPE_FT_RSN_PSK; - match = true; - break; - } - - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_RSN_PSK_SHA256)) { - neg_auth = WLAN_AUTH_TYPE_RSN_PSK_SHA256; - match = true; - break; - } - } - /* 8021X SHA256 */ - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_SHA256_IEEE8021X))) { - if (is_adaptive_11r && - (filter_akm == WLAN_AUTH_TYPE_FT_RSN)) { - neg_auth = WLAN_AUTH_TYPE_FT_RSN; - match = true; - break; - } - - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_RSN_8021X_SHA256)) { - neg_auth = WLAN_AUTH_TYPE_RSN_8021X_SHA256; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_SUITEB_EAP_SHA256))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_SUITEB_EAP_SHA256)) { - neg_auth = WLAN_AUTH_TYPE_SUITEB_EAP_SHA256; - match = true; - break; - } - } - if (scm_is_cipher_match(rsn.akm_suites, - rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_SUITEB_EAP_SHA384))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_SUITEB_EAP_SHA384)) { - neg_auth = WLAN_AUTH_TYPE_SUITEB_EAP_SHA384; - match = true; - break; - } - } - - if (scm_is_cipher_match(rsn.akm_suites, rsn.akm_suite_count, - WLAN_RSN_SEL(WLAN_AKM_FT_SAE))) { - if (match_any_akm || - (filter_akm == WLAN_AUTH_TYPE_FT_SAE)) { - neg_auth = WLAN_AUTH_TYPE_FT_SAE; - match = true; - break; - } - } - - if (scm_is_cipher_match(rsn.akm_suites, rsn.akm_suite_count, - WLAN_RSN_SEL( - WLAN_AKM_FT_SUITEB_EAP_SHA384))) { - if (match_any_akm || - (filter_akm == - WLAN_AUTH_TYPE_FT_SUITEB_EAP_SHA384)) { - neg_auth = WLAN_AUTH_TYPE_FT_SUITEB_EAP_SHA384; - match = true; - break; - } - } - } - - if (!match) { - scm_debug("%pM : akm suites didn't match", - db_entry->bssid.bytes); - return false; - } - - if (!filter->ignore_pmf_cap) - match = scm_check_pmf_match(filter, db_entry, &rsn); - - if (match) { - security->auth_type = neg_auth; - security->mc_enc = neg_mccipher; - } - - return match; -} - -/** - * scm_is_wpa_mcast_cipher_match() - match the wpa mcast cipher type with AP's - * mcast cipher - * @wpa: AP's WPA IE - * @filter: scan filter - * @neg_mccipher: negotiated mc cipher if matched. - * - * Return: true if mc cipher is negotiated - */ -static bool -scm_is_wpa_mcast_cipher_match(struct wlan_wpa_ie *wpa, - struct scan_filter *filter, enum wlan_enc_type *neg_mccipher) -{ - int i; - bool match; - uint8_t cipher_type; - - if (!wpa || !neg_mccipher || !filter) - return false; - - for (i = 0; i < filter->num_of_mc_enc_type; i++) { - - if (filter->mc_enc_type[i] == WLAN_ENCRYPT_TYPE_ANY) { - /* Try the more secured ones first. */ - - /* Check AES */ - cipher_type = WLAN_CSE_CCMP; - match = scm_is_cipher_match(&wpa->mc_cipher, 1, - WLAN_WPA_SEL(cipher_type)); - if (match) { - *neg_mccipher = WLAN_ENCRYPT_TYPE_AES; - return true; - } - /* Check TKIP */ - cipher_type = WLAN_CSE_TKIP; - match = scm_is_cipher_match(&wpa->mc_cipher, 1, - WLAN_WPA_SEL(cipher_type)); - if (match) { - *neg_mccipher = WLAN_ENCRYPT_TYPE_TKIP; - return true; - } - } else { - cipher_type = - scm_get_cipher_suite_type(filter->mc_enc_type[i]); - match = scm_is_cipher_match(&wpa->mc_cipher, 1, - WLAN_WPA_SEL(cipher_type)); - if (match) { - *neg_mccipher = filter->mc_enc_type[i]; - return true; - } - } - } - - return false; -} - -/** - * scm_is_wpa_security() - Check if scan entry support WPA security - * @filter: scan filter - * @db_entry: db entry - * @security: matched security. - * - * Return: true if WPA security else false - */ -static bool scm_is_wpa_security(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct security_info *security) -{ - int i; - QDF_STATUS status; - uint8_t cipher_type; - bool match_any_akm, match = false; - enum wlan_auth_type neg_auth = WLAN_NUM_OF_SUPPORT_AUTH_TYPE; - enum wlan_enc_type neg_mccipher = WLAN_ENCRYPT_TYPE_NONE; - struct wlan_wpa_ie wpa = {0}; - - if (!security) - return false; - if (!util_scan_entry_wpa(db_entry)) { - scm_debug("%pM : AP doesn't have WPA IE", - db_entry->bssid.bytes); - return false; - } - - status = wlan_parse_wpa_ie(util_scan_entry_wpa(db_entry), &wpa); - if (QDF_IS_STATUS_ERROR(status)) { - scm_err("failed to parse WPA IE, status %d", status); - scm_hex_dump(QDF_TRACE_LEVEL_DEBUG, - util_scan_entry_wpa(db_entry), - util_scan_get_wpa_len(db_entry)); - return false; - } - - cipher_type = - scm_get_cipher_suite_type(security->uc_enc); - match = scm_is_cipher_match(wpa.uc_ciphers, - wpa.uc_cipher_count, WLAN_WPA_SEL(cipher_type)); - if (!match) { - scm_debug("%pM : unicase cipher didn't match", - db_entry->bssid.bytes); - return false; - } - - match = scm_is_wpa_mcast_cipher_match(&wpa, filter, &neg_mccipher); - if (!match) { - scm_debug("%pM : mcast cipher didn't match", - db_entry->bssid.bytes); - return false; - } - - /* Initializing with false as it has true value already */ - match = false; - for (i = 0; i < filter->num_of_auth; i++) { - - if (filter->auth_type[i] == WLAN_AUTH_TYPE_ANY) - match_any_akm = true; - else - match_any_akm = false; - /* - * Ciphers are supported, Match authentication algorithm and - * pick first matching authtype. - */ - /**/ - if (scm_is_cipher_match(wpa.auth_suites, - wpa.auth_suite_count, - WLAN_WPA_SEL(WLAN_AKM_IEEE8021X))) { - if (match_any_akm || (WLAN_AUTH_TYPE_WPA == - filter->auth_type[i])) { - neg_auth = WLAN_AUTH_TYPE_WPA; - match = true; - break; - } - } - if (scm_is_cipher_match(wpa.auth_suites, - wpa.auth_suite_count, - WLAN_WPA_SEL(WLAN_AKM_PSK))) { - if (match_any_akm || (WLAN_AUTH_TYPE_WPA_PSK == - filter->auth_type[i])) { - neg_auth = WLAN_AUTH_TYPE_WPA_PSK; - match = true; - break; - } - } - if (scm_is_cipher_match(wpa.auth_suites, - wpa.auth_suite_count, - WLAN_WPA_CCKM_AKM)) { - if (match_any_akm || (WLAN_AUTH_TYPE_CCKM_WPA == - filter->auth_type[i])) { - neg_auth = WLAN_AUTH_TYPE_CCKM_WPA; - match = true; - break; - } - } - } - - if (!match) - scm_debug("%pM : akm didn't match", db_entry->bssid.bytes); - - if (match) { - security->auth_type = neg_auth; - security->mc_enc = neg_mccipher; - } - - return match; -} - -/** - * scm_is_wapi_security() - Check if scan entry support WAPI security - * @filter: scan filter - * @db_entry: db entry - * @security: matched security. - * - * Return: true if WAPI security else false - */ -static bool scm_is_wapi_security(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct security_info *security) -{ - int i; - uint8_t cipher_type; - bool match = false; - enum wlan_auth_type neg_auth = WLAN_NUM_OF_SUPPORT_AUTH_TYPE; - enum wlan_enc_type neg_mccipher = WLAN_ENCRYPT_TYPE_NONE; - struct wlan_wapi_ie wapi = {0}; - - if (!security) - return false; - if (!util_scan_entry_wapi(db_entry)) { - scm_debug("%pM : mcast cipher didn't match", - db_entry->bssid.bytes); - return false; - } - - wlan_parse_wapi_ie( - util_scan_entry_wapi(db_entry), &wapi); - - cipher_type = - scm_get_cipher_suite_type(security->uc_enc); - match = scm_is_cipher_match(wapi.uc_cipher_suites, - wapi.uc_cipher_count, WLAN_WAPI_SEL(cipher_type)); - if (!match) { - scm_debug("%pM : unicast cipher didn't match", - db_entry->bssid.bytes); - return false; - } - - for (i = 0; i < filter->num_of_mc_enc_type; i++) { - cipher_type = - scm_get_cipher_suite_type( - filter->mc_enc_type[i]); - match = scm_is_cipher_match(&wapi.mc_cipher_suite, - 1, WLAN_WAPI_SEL(cipher_type)); - if (match) - break; - } - if (!match) { - scm_debug("%pM : mcast cipher didn't match", - db_entry->bssid.bytes); - return false; - } - neg_mccipher = filter->mc_enc_type[i]; - - if (scm_is_cipher_match(wapi.akm_suites, - wapi.akm_suite_count, - WLAN_WAPI_SEL(WLAN_WAI_CERT_OR_SMS4))) { - neg_auth = - WLAN_AUTH_TYPE_WAPI_WAI_CERTIFICATE; - } else if (scm_is_cipher_match(wapi.akm_suites, - wapi.akm_suite_count, WLAN_WAPI_SEL(WLAN_WAI_PSK))) { - neg_auth = WLAN_AUTH_TYPE_WAPI_WAI_PSK; - } else { - scm_debug("%pM : akm is not supported", - db_entry->bssid.bytes); - return false; - } - - match = false; - for (i = 0; i < filter->num_of_auth; i++) { - if (filter->auth_type[i] == neg_auth) { - match = true; - break; - } - } - - if (!match) - scm_debug("%pM : akm suite didn't match", - db_entry->bssid.bytes); - if (match) { - security->auth_type = neg_auth; - security->mc_enc = neg_mccipher; - } - - return match; -} - -/** - * scm_is_def_security() - Check if any security in filter match - * @filter: scan filter - * @db_entry: db entry - * @security: matched security. - * - * Return: true if any security else false - */ -static bool scm_is_def_security(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct security_info *security) -{ - - /* It is allowed to match anything. Try the more secured ones first. */ - /* Check GCMP_256 first */ - security->uc_enc = WLAN_ENCRYPT_TYPE_AES_GCMP_256; - if (scm_is_rsn_security(filter, db_entry, security)) - return true; - - /* Check GCMP */ - security->uc_enc = WLAN_ENCRYPT_TYPE_AES_GCMP; - if (scm_is_rsn_security(filter, db_entry, security)) - return true; - - /* Check AES */ - security->uc_enc = WLAN_ENCRYPT_TYPE_AES; - if (scm_is_rsn_security(filter, db_entry, security)) - return true; - if (scm_is_wpa_security(filter, db_entry, security)) - return true; - - /* Check TKIP */ - security->uc_enc = WLAN_ENCRYPT_TYPE_TKIP; - if (scm_is_rsn_security(filter, db_entry, security)) - return true; - if (scm_is_wpa_security(filter, db_entry, security)) - return true; - - /* Check AES */ - security->uc_enc = WLAN_ENCRYPT_TYPE_AES; - if (scm_is_wpa_security(filter, db_entry, security)) - return true; - - /* Check TKIP */ - security->uc_enc = WLAN_ENCRYPT_TYPE_TKIP; - if (scm_is_wpa_security(filter, db_entry, security)) - return true; - - /* Check WAPI */ - security->uc_enc = WLAN_ENCRYPT_TYPE_WPI; - if (scm_is_wapi_security(filter, db_entry, security)) - return true; - - security->uc_enc = WLAN_ENCRYPT_TYPE_WEP104; - if (scm_is_wep_security(filter, db_entry, security)) - return true; - security->uc_enc = WLAN_ENCRYPT_TYPE_WEP40; - if (scm_is_wep_security(filter, db_entry, security)) - return true; - security->uc_enc = WLAN_ENCRYPT_TYPE_WEP104_STATICKEY; - if (scm_is_wep_security(filter, db_entry, security)) - return true; - security->uc_enc = WLAN_ENCRYPT_TYPE_WEP40_STATICKEY; - if (scm_is_wep_security(filter, db_entry, security)) - return true; - - /* It must be open and no enc */ - if (db_entry->cap_info.wlan_caps.privacy) - return false; - - security->auth_type = WLAN_AUTH_TYPE_OPEN_SYSTEM; - security->mc_enc = WLAN_ENCRYPT_TYPE_NONE; - security->uc_enc = WLAN_ENCRYPT_TYPE_NONE; - - return true; -} - -/** - * scm_is_security_match() - Check if security in filter match - * @filter: scan filter - * @db_entry: db entry - * @security: matched security. - * - * Return: true if security match else false - */ -static bool scm_is_security_match(struct scan_filter *filter, - struct scan_cache_entry *db_entry, - struct security_info *security) -{ - int i; - bool match = false; - struct security_info local_security = {0}; - - if (!filter->num_of_enc_type) - return true; - - for (i = 0; (i < filter->num_of_enc_type) && - !match; i++) { - - local_security.uc_enc = - filter->enc_type[i]; - - switch (filter->enc_type[i]) { - case WLAN_ENCRYPT_TYPE_NONE: - match = scm_is_open_security(filter, - db_entry, &local_security); - break; - case WLAN_ENCRYPT_TYPE_WEP40_STATICKEY: - case WLAN_ENCRYPT_TYPE_WEP104_STATICKEY: - case WLAN_ENCRYPT_TYPE_WEP40: - case WLAN_ENCRYPT_TYPE_WEP104: - match = scm_is_wep_security(filter, - db_entry, &local_security); - break; - case WLAN_ENCRYPT_TYPE_TKIP: - case WLAN_ENCRYPT_TYPE_AES: - case WLAN_ENCRYPT_TYPE_AES_GCMP: - case WLAN_ENCRYPT_TYPE_AES_GCMP_256: - /* First check if there is a RSN match */ - match = scm_is_rsn_security(filter, db_entry, - &local_security); - /* If not RSN, then check WPA match */ - if (!match) - match = scm_is_wpa_security(filter, - db_entry, &local_security); - break; - case WLAN_ENCRYPT_TYPE_WPI:/* WAPI */ - match = scm_is_wapi_security(filter, - db_entry, &local_security); - break; - case WLAN_ENCRYPT_TYPE_ANY: - default: - match = scm_is_def_security(filter, db_entry, - &local_security); - break; - } - } - - if (match && security) - qdf_mem_copy(security, &local_security, sizeof(*security)); - - return match; -} - -static bool scm_ignore_ssid_check_for_owe(struct scan_filter *filter, - struct scan_cache_entry *db_entry) -{ - int i; - - if (util_scan_entry_is_hidden_ap(db_entry)) { - for (i = 0; i < filter->num_of_auth; i++) { - if (filter->auth_type[i] == WLAN_AUTH_TYPE_OWE && - util_is_bssid_match(&filter->bssid_hint, - &db_entry->bssid)) { - return true; - } - } - } - - return false; -} -#endif - #ifdef WLAN_FEATURE_FILS_SK /** * scm_is_fils_config_match() - Check if FILS config matches diff --git a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h index d571a2ab2bcf..fa4980ed6ff8 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h +++ b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h @@ -237,22 +237,13 @@ struct scan_cache_node { * @ucastcipherset: unicast cipher set * @mcastcipherset: multicast cipher set * @mgmtcipherset: mgmt cipher set - * @uc_enc: unicast cipher - * @mc_enc: multicast cipher - * @auth_type: key management */ struct security_info { -#ifdef WLAN_SCAN_SECURITY_FILTER_V1 uint32_t authmodeset; uint32_t key_mgmt; uint32_t ucastcipherset; uint32_t mcastcipherset; uint32_t mgmtcipherset; -#else - enum wlan_enc_type uc_enc; - enum wlan_enc_type mc_enc; - enum wlan_auth_type auth_type; -#endif }; /** @@ -485,9 +476,6 @@ struct fils_filter_info { * @num_of_bssid: number of bssid passed * @num_of_ssid: number of ssid * @num_of_channels: number of channels - * @num_of_auth: number of auth types - * @num_of_enc_type: number of unicast enc type - * @num_of_mc_enc_type: number of multicast enc type * @pmf_cap: Pmf capability * @ignore_pmf_cap: Ignore pmf capability match * @dot11_mode: operating modes 0 mean any @@ -506,9 +494,6 @@ struct fils_filter_info { * @ucastcipherset: unicast cipher set * @mcastcipherset: multicast cipher set * @mgmtcipherset: mgmt cipher set - * @auth_type: auth type list - * @enc_type: unicast enc type list - * @mc_enc_type: multicast cast enc type list * @fils_scan_filter: FILS info * @bssid_hint: Mac address of bssid_hint */ @@ -518,12 +503,7 @@ struct scan_filter { bool rrm_measurement_filter; uint8_t num_of_bssid; uint8_t num_of_ssid; - uint8_t num_of_channels; -#ifndef WLAN_SCAN_SECURITY_FILTER_V1 - uint8_t num_of_auth; - uint8_t num_of_enc_type; - uint8_t num_of_mc_enc_type; -#endif + uint16_t num_of_channels; enum wlan_pmf_cap pmf_cap; bool ignore_pmf_cap; enum wlan_phymode dot11_mode; @@ -535,17 +515,11 @@ struct scan_filter { struct qdf_mac_addr bssid_list[WLAN_SCAN_FILTER_NUM_BSSID]; struct wlan_ssid ssid_list[WLAN_SCAN_FILTER_NUM_SSID]; qdf_freq_t chan_freq_list[NUM_CHANNELS]; -#ifdef WLAN_SCAN_SECURITY_FILTER_V1 uint32_t authmodeset; uint32_t key_mgmt; uint32_t ucastcipherset; uint32_t mcastcipherset; uint32_t mgmtcipherset; -#else - enum wlan_auth_type auth_type[WLAN_NUM_OF_SUPPORT_AUTH_TYPE]; - enum wlan_enc_type enc_type[WLAN_NUM_OF_ENCRYPT_TYPE]; - enum wlan_enc_type mc_enc_type[WLAN_NUM_OF_ENCRYPT_TYPE]; -#endif #ifdef WLAN_FEATURE_FILS_SK struct fils_filter_info fils_scan_filter; #endif