Browse Source

qcacmn: Fix return type of auth type and akm

Currently api osif_nl_to_crypto_auth_type is trying to convert
the nl specific auth types to driver specific auth types but
it does not return the correct value, this api always returns
auth type as none as it never updates the return value after
the initialization.

While parsing WPA and WAPI, open authmode and cipher and akm are
set as none by default.

Thus return converted value of the auth type. Also fix the
return type of the akm conversion. Also avoid setting
open authmode and cipher and akm as none while parsing WPA
and WAPI ie.

Change-Id: I260e58a28ddbf6b20a290488e205586a624c9b46
CRs-Fixed: 2725323
Ashish Kumar Dhanotiya 5 years ago
parent
commit
eba983ed1e

+ 6 - 5
os_if/linux/crypto/inc/wlan_nl_to_crypto_params.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -30,9 +30,10 @@
  * set the crypto auth type for corresponding auth type received
  * from NL
  *
- * Return: crypto auth type, negative value for failure
+ * Return: crypto auth type
  */
-int osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type);
+wlan_crypto_auth_mode
+osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type);
 
 /**
  * osif_nl_to_crypto_akm_type() - populate akm type for crypto
@@ -41,9 +42,9 @@ int osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type);
  * set the crypto akm type for corresponding akm type received
  * from NL
  *
- * Return: crypto akm type, negative value for failure
+ * Return: crypto akm type
  */
-int osif_nl_to_crypto_akm_type(u32 key_mgmt);
+wlan_crypto_key_mgmt osif_nl_to_crypto_akm_type(u32 key_mgmt);
 
 /**
  * osif_nl_to_crypto_cipher_type() - populate cipher type for crypto

+ 11 - 9
os_if/linux/crypto/src/wlan_nl_to_crypto_params.c

@@ -276,7 +276,8 @@ static const struct osif_cipher_crypto_mapping
 #endif
 };
 
-int osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type)
+wlan_crypto_auth_mode
+osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type)
 {
 	wlan_crypto_auth_mode crypto_auth_type = WLAN_CRYPTO_AUTH_NONE;
 
@@ -284,15 +285,17 @@ int osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type)
 	    auth_type >= QDF_ARRAY_SIZE(osif_auth_type_crypto_mapping)) {
 		QDF_TRACE_ERROR(QDF_MODULE_ID_OS_IF, "Unknown type: %d",
 				auth_type);
-		return -EINVAL;
+		return crypto_auth_type;
 	}
+
+	crypto_auth_type = osif_auth_type_crypto_mapping[auth_type];
 	QDF_TRACE_DEBUG(QDF_MODULE_ID_OS_IF, "Auth type, NL: %d, crypto: %d",
-			auth_type, osif_auth_type_crypto_mapping[auth_type]);
+			auth_type, crypto_auth_type);
 
 	return crypto_auth_type;
 }
 
-int osif_nl_to_crypto_akm_type(u32 key_mgmt)
+wlan_crypto_key_mgmt osif_nl_to_crypto_akm_type(u32 key_mgmt)
 {
 	uint8_t index;
 	wlan_crypto_key_mgmt crypto_akm_type = WLAN_CRYPTO_KEY_MGMT_NONE;
@@ -307,13 +310,12 @@ int osif_nl_to_crypto_akm_type(u32 key_mgmt)
 			break;
 		}
 	}
-	if (!akm_type_crypto_exist) {
+	if (!akm_type_crypto_exist)
 		QDF_TRACE_ERROR(QDF_MODULE_ID_OS_IF, "Unknown type: %d",
 				key_mgmt);
-		return -EINVAL;
-	}
-	QDF_TRACE_DEBUG(QDF_MODULE_ID_OS_IF, "Akm suite, NL: %d, crypto: %d",
-			key_mgmt, crypto_akm_type);
+	else
+		QDF_TRACE_DEBUG(QDF_MODULE_ID_OS_IF, "Akm suite, NL: %d, crypto: %d",
+				key_mgmt, crypto_akm_type);
 
 	return crypto_akm_type;
 }

+ 0 - 8
umac/cmn_services/crypto/src/wlan_crypto_global_api.c

@@ -2517,7 +2517,6 @@ QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *crypto_params,
 	 * version, mcast cipher, and 2 selector counts.
 	 * Other, variable-length data, must be checked separately.
 	 */
-	RESET_AUTHMODE(crypto_params);
 	SET_AUTHMODE(crypto_params, WLAN_CRYPTO_AUTH_WPA);
 
 	if (len < 14)
@@ -2532,7 +2531,6 @@ QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *crypto_params,
 	frm += 2, len -= 2;
 
 	/* multicast/group cipher */
-	RESET_MCAST_CIPHERS(crypto_params);
 	w = wlan_crypto_wpa_suite_to_cipher(frm);
 	if (w < 0)
 		return QDF_STATUS_E_INVAL;
@@ -2545,7 +2543,6 @@ QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *crypto_params,
 	if (len < n*4+2)
 		return QDF_STATUS_E_INVAL;
 
-	RESET_UCAST_CIPHERS(crypto_params);
 	for (; n > 0; n--) {
 		w = wlan_crypto_wpa_suite_to_cipher(frm);
 		if (w < 0)
@@ -2564,7 +2561,6 @@ QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *crypto_params,
 		return QDF_STATUS_E_INVAL;
 
 	w = 0;
-	RESET_KEY_MGMT(crypto_params);
 	for (; n > 0; n--) {
 		w = wlan_crypto_wpa_suite_to_keymgmt(frm);
 		if (w < 0)
@@ -3136,7 +3132,6 @@ QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params,
 	 * version, mcast cipher, and 2 selector counts.
 	 * Other, variable-length data, must be checked separately.
 	 */
-	RESET_AUTHMODE(crypto_params);
 	SET_AUTHMODE(crypto_params, WLAN_CRYPTO_AUTH_WAPI);
 
 	if (len < WLAN_CRYPTO_WAPI_IE_LEN)
@@ -3155,7 +3150,6 @@ QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params,
 	if (len < n*4+2)
 		return QDF_STATUS_E_INVAL;
 
-	RESET_KEY_MGMT(crypto_params);
 	for (; n > 0; n--) {
 		w = wlan_crypto_wapi_keymgmt(frm);
 		if (w < 0)
@@ -3171,7 +3165,6 @@ QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params,
 	if (len < n*4+2)
 		return QDF_STATUS_E_INVAL;
 
-	RESET_UCAST_CIPHERS(crypto_params);
 	for (; n > 0; n--) {
 		w = wlan_crypto_wapi_suite_to_cipher(frm);
 		if (w < 0)
@@ -3184,7 +3177,6 @@ QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params,
 		return QDF_STATUS_E_INVAL;
 
 	/* multicast/group cipher */
-	RESET_MCAST_CIPHERS(crypto_params);
 	w = wlan_crypto_wapi_suite_to_cipher(frm);
 
 	if (w < 0)