From 91be4be6dea0ac7b9f28c5f1dda7c3e6ac24e136 Mon Sep 17 00:00:00 2001 From: Pragaspathi Thilagaraj Date: Tue, 14 Apr 2020 01:11:09 +0530 Subject: [PATCH] qcacmn: Introduce crypto API for single pmk AP cache management Add new crypto API to set the single PMK AP flag in crypto pmksa entry and to clear the BSSID entries in the crypto pmk cache with the SAE single pmk flag set. Clear the entries with Sae single pmk flag on connection and roaming success case. Mark the BSS as Sae pmk capable after initial connection and roaming if the AP advertises the VSIE Change-Id: I42ca0c3a70945f974eec1065661ac0b781096126 CRs-Fixed: 2652936 --- .../crypto/inc/wlan_crypto_global_api.h | 38 +++++++++++ .../crypto/inc/wlan_crypto_global_def.h | 4 ++ .../crypto/src/wlan_crypto_global_api.c | 65 +++++++++++++++++++ 3 files changed, 107 insertions(+) diff --git a/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h b/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h index f9e0c17fdee4..c6672139f193 100644 --- a/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h +++ b/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h @@ -923,4 +923,42 @@ QDF_STATUS wlan_crypto_set_del_pmksa(struct wlan_objmgr_vdev *vdev, struct wlan_crypto_pmksa *pmksa, bool set); +#if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) +/** + * wlan_crypto_selective_clear_sae_single_pmk_entries - Clear the PMK entries + * for BSS which have the single PMK flag set other than the current connected + * AP + * @vdev: Vdev + * @conn_bssid: Connected bssid + */ +void +wlan_crypto_selective_clear_sae_single_pmk_entries( + struct wlan_objmgr_vdev *vdev, struct qdf_mac_addr *conn_bssid); + +/** + * wlan_crypto_set_sae_single_pmk_bss_cap - Set the peer SAE sinlge pmk + * feature supported status + * @vdev: Vdev + * @bssid: BSSID for which the flag is to be set + * @single_pmk_capable_bss: Flag to indicate Sae single pmk supported BSSID or + * not + */ +void wlan_crypto_set_sae_single_pmk_bss_cap(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr *bssid, + bool single_pmk_capable_bss); +#else +static inline void +wlan_crypto_selective_clear_sae_single_pmk_entries( + struct wlan_objmgr_vdev *vdev, struct qdf_mac_addr *conn_bssid) +{ +} + +static inline +void wlan_crypto_set_sae_single_pmk_bss_cap(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr *bssid, + bool single_pmk_capable_bss) +{ +} +#endif + #endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */ diff --git a/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h b/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h index 3121af755364..b3d2c2112cbc 100644 --- a/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h +++ b/umac/cmn_services/crypto/inc/wlan_crypto_global_def.h @@ -226,6 +226,7 @@ enum wlan_crypto_key_type { * @ssid_len: ssid length * @ssid: ssid information * @cache_id: cache id + * @single_pmk_supported: SAE single pmk supported BSS */ struct wlan_crypto_pmksa { struct qdf_mac_addr bssid; @@ -235,6 +236,9 @@ struct wlan_crypto_pmksa { uint8_t ssid_len; uint8_t ssid[WLAN_SSID_MAX_LEN]; uint8_t cache_id[WLAN_CACHE_ID_LEN]; +#if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) + bool single_pmk_supported; +#endif }; /** diff --git a/umac/cmn_services/crypto/src/wlan_crypto_global_api.c b/umac/cmn_services/crypto/src/wlan_crypto_global_api.c index cb151db0dce5..15eff6bfefe3 100644 --- a/umac/cmn_services/crypto/src/wlan_crypto_global_api.c +++ b/umac/cmn_services/crypto/src/wlan_crypto_global_api.c @@ -4320,4 +4320,69 @@ void wlan_crypto_update_set_key_peer(struct wlan_objmgr_vdev *vdev, qdf_mem_copy(crypto_key->macaddr, peer_mac, QDF_MAC_ADDR_SIZE); } + +#if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) +void wlan_crypto_selective_clear_sae_single_pmk_entries( + struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr *conn_bssid) +{ + struct wlan_crypto_params *crypto_params; + struct wlan_crypto_comp_priv *crypto_priv; + int i; + + crypto_priv = (struct wlan_crypto_comp_priv *) + wlan_get_vdev_crypto_obj(vdev); + + if (!crypto_priv) { + crypto_err("crypto_priv NULL"); + return; + } + + crypto_params = &crypto_priv->crypto_params; + + for (i = 0; i < WLAN_CRYPTO_MAX_PMKID; i++) { + if (!crypto_params->pmksa[i]) + continue; + + if (crypto_params->pmksa[i]->single_pmk_supported && + !qdf_is_macaddr_equal(conn_bssid, + &crypto_params->pmksa[i]->bssid)) { + qdf_mem_zero(crypto_params->pmksa[i], + sizeof(struct wlan_crypto_pmksa)); + qdf_mem_free(crypto_params->pmksa[i]); + crypto_params->pmksa[i] = NULL; + } + } +} + +void wlan_crypto_set_sae_single_pmk_bss_cap(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr *bssid, + bool single_pmk_capable_bss) +{ + struct wlan_crypto_params *crypto_params; + struct wlan_crypto_comp_priv *crypto_priv; + int i; + + crypto_priv = (struct wlan_crypto_comp_priv *) + wlan_get_vdev_crypto_obj(vdev); + + if (!crypto_priv) { + crypto_err("crypto_priv NULL"); + return; + } + + crypto_params = &crypto_priv->crypto_params; + + for (i = 0; i < WLAN_CRYPTO_MAX_PMKID; i++) { + if (!crypto_params->pmksa[i]) + continue; + + if (qdf_is_macaddr_equal(bssid, + &crypto_params->pmksa[i]->bssid)) + crypto_params->pmksa[i]->single_pmk_supported = + single_pmk_capable_bss; + } +} +#endif + #endif