qcacmn: Fix WEP functionality in converged set key

Fix WEP security mode issues in converged set key.

Change-Id: Idd4071c8aef141cb45db9006c5773a94b352879a
CRs-Fixed: 2400864
This commit is contained in:
Varun Reddy Yeturu
2019-02-15 16:04:36 -08:00
committed by nshrivas
parent 0e2d7fc5ad
commit 09a3b065f9
4 changed files with 31 additions and 6 deletions

View File

@@ -38,10 +38,23 @@ static void wlan_cfg80211_translate_key(struct wlan_objmgr_vdev *vdev,
qdf_mem_zero(crypto_key, sizeof(*crypto_key));
crypto_key->keylen = params->key_len;
crypto_key->keyix = key_index;
cfg80211_debug("key_type %d, opmode %d, key_len %d, seq_len %d",
key_type, vdev->vdev_mlme.vdev_opmode,
params->key_len, params->seq_len);
qdf_mem_copy(&crypto_key->keyval[0], params->key, params->key_len);
qdf_mem_copy(&crypto_key->keyrsc[0], params->seq, params->seq_len);
crypto_key->cipher_type = osif_nl_to_crypto_cipher_type(params->cipher);
if (IS_WEP_CIPHER(crypto_key->cipher_type) && !mac_addr) {
/*
* This is a valid scenario in case of WEP, where-in the
* keys are passed by the user space during the connect request
* but since we did not connect yet, so we do not know the peer
* address yet.
*/
cfg80211_debug("No Mac Address to copy");
return;
}
if (key_type == WLAN_CRYPTO_KEY_TYPE_UNICAST) {
qdf_mem_copy(&crypto_key->macaddr, mac_addr, QDF_MAC_ADDR_SIZE);
} else {
@@ -54,8 +67,7 @@ static void wlan_cfg80211_translate_key(struct wlan_objmgr_vdev *vdev,
vdev->vdev_mlme.macaddr,
QDF_MAC_ADDR_SIZE);
}
cfg80211_debug("key_type %d, opmode %d, mac %pM", key_type,
vdev->vdev_mlme.vdev_opmode, crypto_key->macaddr);
cfg80211_debug("mac %pM", crypto_key->macaddr);
}
int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
@@ -76,10 +88,6 @@ int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
cfg80211_err("Key params is NULL");
return -EINVAL;
}
if ((key_type == WLAN_CRYPTO_KEY_TYPE_UNICAST) && !mac_addr) {
cfg80211_err("mac_addr is NULL for pairwise Key");
return -EINVAL;
}
cipher_len = osif_nl_to_crypto_cipher_len(params->cipher);
if (cipher_len < 0 || params->key_len < cipher_len) {
cfg80211_err("cipher length %d less than reqd len %d",
@@ -87,6 +95,13 @@ int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
return -EINVAL;
}
cipher = osif_nl_to_crypto_cipher_type(params->cipher);
if (!IS_WEP_CIPHER(cipher)) {
if ((key_type == WLAN_CRYPTO_KEY_TYPE_UNICAST) &&
!mac_addr) {
cfg80211_err("mac_addr is NULL for pairwise Key");
return -EINVAL;
}
}
status = wlan_crypto_validate_key_params(cipher, key_index,
params->key_len,
params->seq_len);

View File

@@ -182,6 +182,8 @@ QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
switch (req->cipher_type) {
case WLAN_CRYPTO_CIPHER_WEP:
case WLAN_CRYPTO_CIPHER_WEP_40:
case WLAN_CRYPTO_CIPHER_WEP_104:
def_tx_idx = wlan_crypto_get_default_key_idx(vdev, false);
if (pairwise && params.key_idx == def_tx_idx)
params.key_flags |= TX_USAGE;
@@ -203,6 +205,7 @@ QDF_STATUS target_if_crypto_set_key(struct wlan_objmgr_vdev *vdev,
params.key_len = req->keylen;
if (peer) {
/* Set PN check & security type in data path */
qdf_mem_copy(&pn[0], &params.key_rsc_ctr, sizeof(pn));
cdp_set_pn_check(soc, txrx_vdev, peer, sec_type, pn);
cdp_set_key(soc, peer, pairwise, (uint32_t *)(req->keyval +
WLAN_CRYPTO_IV_SIZE + WLAN_CRYPTO_MIC_LEN));

View File

@@ -207,6 +207,9 @@ enum wlan_crypto_key_type {
WLAN_CRYPTO_KEY_TYPE_GROUP,
};
#define IS_WEP_CIPHER(_c) ((_c == WLAN_CRYPTO_CIPHER_WEP) || \
(_c == WLAN_CRYPTO_CIPHER_WEP_40) || \
(_c == WLAN_CRYPTO_CIPHER_WEP_104))
/**
* struct wlan_crypto_pmksa - structure of crypto to contain pmkid
* @bssid: bssid for which pmkid is saved

View File

@@ -4465,6 +4465,8 @@ uint8_t wlan_crypto_cipher_to_wmi_cipher(
case WLAN_CRYPTO_CIPHER_NONE:
return WMI_CIPHER_NONE;
case WLAN_CRYPTO_CIPHER_WEP:
case WLAN_CRYPTO_CIPHER_WEP_40:
case WLAN_CRYPTO_CIPHER_WEP_104:
return WMI_CIPHER_WEP;
case WLAN_CRYPTO_CIPHER_TKIP:
return WMI_CIPHER_TKIP;
@@ -4494,6 +4496,8 @@ enum cdp_sec_type wlan_crypto_cipher_to_cdp_sec_type(
case WLAN_CRYPTO_CIPHER_NONE:
return cdp_sec_type_none;
case WLAN_CRYPTO_CIPHER_WEP:
case WLAN_CRYPTO_CIPHER_WEP_40:
case WLAN_CRYPTO_CIPHER_WEP_104:
return cdp_sec_type_wep104;
case WLAN_CRYPTO_CIPHER_TKIP:
return cdp_sec_type_tkip;