qcacmn: Add APIs to translate NL to crypto param
Add following APIs to translate NL param type to crypto param type. 1.osif_nl_to_crypto_auth_type() 2.osif_nl_to_crypto_akm_type() 3.osif_nl_to_crypto_cipher_type() Change-Id: Iba0d57e63db98cf81ed0ce5c0a79ae7f8239d1a9 CRs-Fixed: 2300761
Esse commit está contido em:
57
os_if/linux/crypto/inc/wlan_nl_to_crypto_params.h
Arquivo normal
57
os_if/linux/crypto/inc/wlan_nl_to_crypto_params.h
Arquivo normal
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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
|
||||
* above copyright notice and this permission notice appear in all
|
||||
* copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: wlan_nl_to_crypto_params.h
|
||||
*
|
||||
* Conversion of NL param type to Crypto param type APIs implementation
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* osif_nl_to_crypto_auth_type() - populate auth type for crypto
|
||||
* @auth_type: NL auth_type
|
||||
*
|
||||
* set the crypto auth type for corresponding auth type received
|
||||
* from NL
|
||||
*
|
||||
* Return: crypto auth type, negative value for failure
|
||||
*/
|
||||
int osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type);
|
||||
|
||||
/**
|
||||
* osif_nl_to_crypto_akm_type() - populate akm type for crypto
|
||||
* @akm_type: NL akm_type
|
||||
*
|
||||
* set the crypto akm type for corresponding akm type received
|
||||
* from NL
|
||||
*
|
||||
* Return: crypto akm type, negative value for failure
|
||||
*/
|
||||
int osif_nl_to_crypto_akm_type(u32 key_mgmt);
|
||||
|
||||
/**
|
||||
* osif_nl_to_crypto_cipher_type() - populate cipher type for crypto
|
||||
* @cipher: NL cipher type
|
||||
*
|
||||
* set the crypto cipher type for corresponding cipher type received
|
||||
* from NL.
|
||||
*
|
||||
* Return: crypto cipher type, negative value for failure
|
||||
*/
|
||||
int osif_nl_to_crypto_cipher_type(u32 cipher);
|
284
os_if/linux/crypto/src/wlan_nl_to_crypto_params.c
Arquivo normal
284
os_if/linux/crypto/src/wlan_nl_to_crypto_params.c
Arquivo normal
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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
|
||||
* above copyright notice and this permission notice appear in all
|
||||
* copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: wlan_nl_to_crypto_params.c
|
||||
*
|
||||
* Conversion of NL param type to Crypto param type APIs implementation
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <net/netlink.h>
|
||||
#include <net/cfg80211.h>
|
||||
|
||||
#include <qdf_types.h>
|
||||
#include "wlan_objmgr_vdev_obj.h"
|
||||
#include <qdf_module.h>
|
||||
|
||||
#include "wlan_nl_to_crypto_params.h"
|
||||
#include "wlan_crypto_global_def.h"
|
||||
|
||||
/**
|
||||
* struct osif_akm_crypto_mapping - mapping akm type received from
|
||||
* NL to internal crypto type
|
||||
* @akm_suite: NL akm type
|
||||
* @akm_type_crypto: akm crypto type
|
||||
*
|
||||
* mapping akm type received from NL to internal crypto type
|
||||
*/
|
||||
struct osif_akm_type_crypto_mapping {
|
||||
u32 akm_suite;
|
||||
wlan_crypto_key_mgmt akm_type_crypto;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct osif_cipher_crypto_mapping - mapping cipher type received from NL
|
||||
* to internal crypto cipher type
|
||||
* @cipher_suite: NL cipher type
|
||||
* @cipher_crypto: cipher crypto type
|
||||
*
|
||||
* mapping cipher type received from NL to internal crypto cipher type
|
||||
*/
|
||||
struct osif_cipher_crypto_mapping {
|
||||
u32 cipher_suite;
|
||||
wlan_crypto_cipher_type cipher_crypto;
|
||||
};
|
||||
|
||||
/**
|
||||
* mapping table for auth type received from NL and cryto auth type
|
||||
*/
|
||||
static const wlan_crypto_auth_mode
|
||||
osif_auth_type_crypto_mapping[] = {
|
||||
[NL80211_AUTHTYPE_AUTOMATIC] = WLAN_CRYPTO_AUTH_AUTO,
|
||||
[NL80211_AUTHTYPE_OPEN_SYSTEM] = WLAN_CRYPTO_AUTH_OPEN,
|
||||
[NL80211_AUTHTYPE_FT] = WLAN_CRYPTO_AUTH_OPEN,
|
||||
[NL80211_AUTHTYPE_SHARED_KEY] = WLAN_CRYPTO_AUTH_SHARED,
|
||||
[NL80211_AUTHTYPE_NETWORK_EAP] = WLAN_CRYPTO_AUTH_8021X,
|
||||
#if defined(WLAN_FEATURE_FILS_SK) && \
|
||||
(defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \
|
||||
(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)))
|
||||
[NL80211_AUTHTYPE_FILS_SK] = WLAN_CRYPTO_AUTH_FILS_SK,
|
||||
#endif
|
||||
[NL80211_AUTHTYPE_SAE] = WLAN_CRYPTO_AUTH_SAE,
|
||||
};
|
||||
|
||||
/* mapping table for akm type received from NL and cryto akm type */
|
||||
static const struct osif_akm_type_crypto_mapping
|
||||
osif_akm_type_crypto_mapping[] = {
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_8021X,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_IEEE8021X,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_PSK,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_PSK,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_8021X_SHA256,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SHA256,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_PSK_SHA256,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_PSK_SHA256,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_SAE,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_SAE,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_FT_OVER_SAE,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_FT_SAE,
|
||||
},
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) || \
|
||||
defined(FEATURE_WLAN_FT_IEEE8021X)
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_FT_8021X,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X,
|
||||
},
|
||||
#endif
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) || \
|
||||
defined(FEATURE_WLAN_FT_PSK)
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_FT_PSK,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_FT_PSK,
|
||||
},
|
||||
#endif
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) || \
|
||||
defined(FEATURE_WLAN_IEEE8021X_SUITE_B)
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_8021X_SUITE_B,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_8021X_SUITE_B_192,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B_192,
|
||||
},
|
||||
#endif
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) || \
|
||||
defined(FEATURE_WLAN_FILS)
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_FILS_SHA256,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_FILS_SHA256,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_FILS_SHA384,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_FILS_SHA384,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_FT_FILS_SHA256,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA256,
|
||||
},
|
||||
{
|
||||
.akm_suite = WLAN_AKM_SUITE_FT_FILS_SHA384,
|
||||
.akm_type_crypto = WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA384,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/* mapping table for cipher type received from NL and cryto cipher type */
|
||||
static const struct osif_cipher_crypto_mapping
|
||||
osif_cipher_crypto_mapping[] = {
|
||||
{
|
||||
.cipher_suite = IW_AUTH_CIPHER_NONE,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_NONE,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_WEP40,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_WEP_40,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_TKIP,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_TKIP,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_CCMP,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_CCM,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_WEP104,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_WEP_104,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_GCMP,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_GCM,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_GCMP_256,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_GCM_256,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_CCMP_256,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_CCM_256,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_AES_CMAC,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_CMAC,
|
||||
},
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_BIP_GMAC_128,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_GMAC,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_BIP_GMAC_256,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_GMAC_256,
|
||||
},
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_BIP_CMAC_256,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_AES_CMAC_256,
|
||||
},
|
||||
#endif
|
||||
#ifdef FEATURE_WLAN_WAPI
|
||||
{
|
||||
.cipher_suite = WLAN_CIPHER_SUITE_SMS4,
|
||||
.cipher_crypto = WLAN_CRYPTO_CIPHER_WAPI_SMS4,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
int osif_nl_to_crypto_auth_type(enum nl80211_auth_type auth_type)
|
||||
{
|
||||
wlan_crypto_auth_mode crypto_auth_type = WLAN_CRYPTO_AUTH_NONE;
|
||||
|
||||
if (auth_type < NL80211_AUTHTYPE_OPEN_SYSTEM ||
|
||||
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;
|
||||
}
|
||||
QDF_TRACE_DEBUG(QDF_MODULE_ID_OS_IF, "Auth type, NL: %d, crypto: %d",
|
||||
auth_type, osif_auth_type_crypto_mapping[auth_type]);
|
||||
|
||||
return crypto_auth_type;
|
||||
}
|
||||
|
||||
int osif_nl_to_crypto_akm_type(u32 key_mgmt)
|
||||
{
|
||||
uint8_t index;
|
||||
wlan_crypto_key_mgmt crypto_akm_type = WLAN_CRYPTO_KEY_MGMT_NONE;
|
||||
bool akm_type_crypto_exist = false;
|
||||
|
||||
for (index = 0; index < QDF_ARRAY_SIZE(osif_akm_type_crypto_mapping);
|
||||
index++) {
|
||||
if (osif_akm_type_crypto_mapping[index].akm_suite == key_mgmt) {
|
||||
crypto_akm_type = osif_akm_type_crypto_mapping[index].
|
||||
akm_type_crypto;
|
||||
akm_type_crypto_exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
return crypto_akm_type;
|
||||
}
|
||||
|
||||
int osif_nl_to_crypto_cipher_type(u32 cipher)
|
||||
{
|
||||
uint8_t index;
|
||||
bool cipher_crypto_exist = false;
|
||||
wlan_crypto_cipher_type crypto_cipher_type = WLAN_CRYPTO_CIPHER_NONE;
|
||||
|
||||
for (index = 0; index < QDF_ARRAY_SIZE(osif_auth_type_crypto_mapping);
|
||||
index++) {
|
||||
if (osif_cipher_crypto_mapping[index].cipher_suite == cipher) {
|
||||
crypto_cipher_type = osif_cipher_crypto_mapping[index].
|
||||
cipher_crypto;
|
||||
cipher_crypto_exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!cipher_crypto_exist) {
|
||||
QDF_TRACE_ERROR(QDF_MODULE_ID_OS_IF, "Unknown type: %d",
|
||||
cipher);
|
||||
return -EINVAL;
|
||||
}
|
||||
QDF_TRACE_DEBUG(QDF_MODULE_ID_OS_IF, "Cipher suite, NL: %d, crypto: %d",
|
||||
cipher, crypto_cipher_type);
|
||||
|
||||
return crypto_cipher_type;
|
||||
}
|
Referência em uma nova issue
Block a user