From 6c641bada49c8557d10c4c113db32f19e1f7a5c2 Mon Sep 17 00:00:00 2001 From: Harprit Chhabada Date: Thu, 28 Jun 2018 14:45:10 -0700 Subject: [PATCH] qcacld-3.0: Populate crypto params Translate the legacy auth type to crypto auth type. Set the crypto auth type under vdev object. Use APIs to translate NL param type to crypto param type from common. Change-Id: I7073d35fe1724d37467bf970cf6bac7bc40045d1 CRs-Fixed: 2285045 --- Kbuild | 8 +-- core/hdd/src/wlan_hdd_cfg80211.c | 105 +++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 4 deletions(-) diff --git a/Kbuild b/Kbuild index 2a532f1a956f..cea983ff82b3 100644 --- a/Kbuild +++ b/Kbuild @@ -594,10 +594,12 @@ OS_IF_INC := -I$(WLAN_COMMON_INC)/os_if/linux \ -I$(WLAN_COMMON_INC)/os_if/linux/scan/inc \ -I$(WLAN_COMMON_INC)/os_if/linux/p2p/inc \ -I$(WLAN_COMMON_INC)/os_if/linux/spectral/inc \ - -I$(WLAN_COMMON_INC)/os_if/linux/tdls/inc + -I$(WLAN_COMMON_INC)/os_if/linux/tdls/inc \ + -I$(WLAN_COMMON_INC)/os_if/linux/crypto/inc OS_IF_OBJ := $(OS_IF_DIR)/linux/p2p/src/wlan_cfg80211_p2p.o \ - $(OS_IF_DIR)/linux/wlan_osif_request_manager.o + $(OS_IF_DIR)/linux/wlan_osif_request_manager.o \ + $(OS_IF_DIR)/linux/crypto/src/wlan_nl_to_crypto_params.o ############ UMAC_DISP ############ UMAC_DISP_DIR := umac/global_umac_dispatcher/lmac_if @@ -1687,9 +1689,7 @@ INCS += $(UMAC_TARGET_GREEN_AP_INC) INCS += $(UMAC_COMMON_INC) INCS += $(UMAC_SPECTRAL_INC) INCS += $(UMAC_TARGET_SPECTRAL_INC) -ifeq ($(CONFIG_CRYPTO_COMPONENT), y) INCS += $(UMAC_CRYPTO_INC) -endif OBJS := $(HDD_OBJS) \ $(DSC_OBJS) \ diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 1f4ac5199463..694e0403bb04 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -122,6 +122,10 @@ #include "wlan_extscan_ucfg_api.h" #include "wlan_mlme_ucfg_api.h" +#include "wlan_crypto_global_api.h" +#include "wlan_nl_to_crypto_params.h" +#include "wlan_crypto_global_def.h" + #define g_mode_rates_size (12) #define a_mode_rates_size (8) @@ -15979,6 +15983,104 @@ static bool hdd_is_wpaie_present(const uint8_t *ie, uint8_t ie_len) return false; } +/** + * hdd_populate_crypto_auth_type() - populate auth type for crypto + * @vdev: pointed to vdev obmgr + * @auth_type: legacy auth_type + * + * set the crypto auth type for corresponding auth type received + * from NL + * + * Return: None + */ +static void hdd_populate_crypto_auth_type(struct wlan_objmgr_vdev *vdev, + enum nl80211_auth_type auth_type) +{ + wlan_crypto_auth_mode crypto_auth_type = + osif_nl_to_crypto_auth_type(auth_type); + + wlan_crypto_set_vdev_param(vdev, + WLAN_CRYPTO_PARAM_AUTH_MODE, + crypto_auth_type); +} + +/** + * hdd_populate_crypto_akm_type() - populate akm type for crypto + * @vdev: pointed to vdev obmgr + * @akm_type: legacy akm_type + * + * set the crypto akm type for corresponding akm type received + * from NL + * + * Return: None + */ +static void hdd_populate_crypto_akm_type(struct wlan_objmgr_vdev *vdev, + u32 key_mgmt) +{ + wlan_crypto_key_mgmt crypto_akm_type = + osif_nl_to_crypto_akm_type(key_mgmt); + + wlan_crypto_set_vdev_param(vdev, + WLAN_CRYPTO_PARAM_KEY_MGMT, + crypto_akm_type); +} + +/** + * hdd_populate_crypto_cipher_type() - populate cipher type for crypto + * @cipher: legacy cipher type + * @vdev: pointed to vdev obmgr + * @cipher_param_type: param type, UCST/MCAST + * + * set the crypto cipher type for corresponding cipher type received + * from NL + * + * Return: None + */ +static void hdd_populate_crypto_cipher_type(u32 cipher, + struct wlan_objmgr_vdev *vdev, + wlan_crypto_param_type + cipher_param_type) +{ + wlan_crypto_cipher_type crypto_cipher_type = + osif_nl_to_crypto_cipher_type(cipher); + + wlan_crypto_set_vdev_param(vdev, + cipher_param_type, + crypto_cipher_type); +} + +/** + * hdd_populate_crypto_params() - set crypto params + * @vdev: Pointer to vdev obh mgr + * @req: Pointer to security parameters + * + * Set Auth, Akm and Cipher type for crypto + * + * Return: None + */ +static void hdd_populate_crypto_params(struct wlan_objmgr_vdev *vdev, + struct cfg80211_connect_params *req) +{ + hdd_populate_crypto_auth_type(vdev, req->auth_type); + + if (req->crypto.n_akm_suites) + hdd_populate_crypto_akm_type(vdev, req->crypto.akm_suites[0]); + + if (req->crypto.n_ciphers_pairwise) { + hdd_populate_crypto_cipher_type(req->crypto.ciphers_pairwise[0], + vdev, + WLAN_CRYPTO_PARAM_UCAST_CIPHER); + } else { + /* Reset previous cipher suite to none */ + hdd_populate_crypto_cipher_type(0, vdev, + WLAN_CRYPTO_PARAM_UCAST_CIPHER); + } + + hdd_populate_crypto_cipher_type(req->crypto.cipher_group, + vdev, + WLAN_CRYPTO_PARAM_MCAST_CIPHER); +} + /** * wlan_hdd_cfg80211_set_privacy() - set security parameters during connection * @adapter: Pointer to adapter @@ -16001,6 +16103,9 @@ static int wlan_hdd_cfg80211_set_privacy(struct hdd_adapter *adapter, roam_profile = hdd_roam_profile(adapter); + /* populate auth,akm and cipher params for crypto */ + hdd_populate_crypto_params(adapter->vdev, req); + /*set authentication type */ status = wlan_hdd_cfg80211_set_auth_type(adapter, req->auth_type);