qcacmn: Add crypto changes for code convergence
At present, the crypto module utilizes the wlan_crypto_comp_priv structure to store crypto keys. However, there is a need to store keys for individual links in n-link MLO. To address this requirement it is proposed to store the key from the vdev level to the psoc level. This change will allow the reuse of a common structure. Change-Id: Idc0d8bb11a80b66c7ded5c930ec0560566398890 CRs-Fixed: 3527400
This commit is contained in:

committed by
Rahul Choudhary

parent
f9ecb01556
commit
aa7c47fe95
@@ -392,8 +392,7 @@ typedef void (*crypto_add_key_callback)(void *context,
|
||||
struct crypto_add_key_result *result);
|
||||
|
||||
/**
|
||||
* struct wlan_crypto_comp_priv - crypto component private structure
|
||||
* @crypto_params: crypto params for the peer
|
||||
* struct wlan_crypto_keys - crypto keys structure
|
||||
* @key: key buffers for this peer
|
||||
* @igtk_key: igtk key buffer for this peer
|
||||
* @bigtk_key: bigtk key buffer for this peer
|
||||
@@ -401,6 +400,22 @@ typedef void (*crypto_add_key_callback)(void *context,
|
||||
* @def_tx_keyid: default key used for this peer
|
||||
* @def_igtk_tx_keyid: default igtk key used for this peer
|
||||
* @def_bigtk_tx_keyid: default bigtk key used for this peer
|
||||
*
|
||||
*/
|
||||
struct wlan_crypto_keys {
|
||||
struct wlan_crypto_key *key[WLAN_CRYPTO_MAX_VLANKEYIX];
|
||||
struct wlan_crypto_key *igtk_key[WLAN_CRYPTO_MAXIGTKKEYIDX];
|
||||
struct wlan_crypto_key *bigtk_key[WLAN_CRYPTO_MAXBIGTKKEYIDX];
|
||||
enum wlan_crypto_cipher_type igtk_key_type;
|
||||
uint8_t def_tx_keyid;
|
||||
uint8_t def_igtk_tx_keyid;
|
||||
uint8_t def_bigtk_tx_keyid;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wlan_crypto_comp_priv - crypto component private structure
|
||||
* @crypto_params: crypto params for the peer
|
||||
* @crypto_key: crypto keys structure for the peer
|
||||
* @fils_aead_set: fils params for this peer
|
||||
* @add_key_ctx: Opaque context to be used by the caller to associate the
|
||||
* add key request with the response
|
||||
@@ -409,13 +424,7 @@ typedef void (*crypto_add_key_callback)(void *context,
|
||||
*/
|
||||
struct wlan_crypto_comp_priv {
|
||||
struct wlan_crypto_params crypto_params;
|
||||
struct wlan_crypto_key *key[WLAN_CRYPTO_MAX_VLANKEYIX];
|
||||
struct wlan_crypto_key *igtk_key[WLAN_CRYPTO_MAXIGTKKEYIDX];
|
||||
struct wlan_crypto_key *bigtk_key[WLAN_CRYPTO_MAXBIGTKKEYIDX];
|
||||
enum wlan_crypto_cipher_type igtk_key_type;
|
||||
uint8_t def_tx_keyid;
|
||||
uint8_t def_igtk_tx_keyid;
|
||||
uint8_t def_bigtk_tx_keyid;
|
||||
struct wlan_crypto_keys crypto_key;
|
||||
uint8_t fils_aead_set;
|
||||
void *add_key_ctx;
|
||||
crypto_add_key_callback add_key_cb;
|
||||
|
@@ -739,7 +739,7 @@ static void wlan_crypto_store_def_keyix(struct wlan_objmgr_vdev *vdev,
|
||||
crypto_err("crypto_priv NULL");
|
||||
return;
|
||||
}
|
||||
crypto_priv->def_tx_keyid = kid;
|
||||
crypto_priv->crypto_key.def_tx_keyid = kid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -760,6 +760,7 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
struct wlan_objmgr_psoc *psoc;
|
||||
struct wlan_objmgr_peer *peer = NULL;
|
||||
struct wlan_crypto_key *key = NULL;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
const struct wlan_crypto_cipher *cipher;
|
||||
uint8_t macaddr[QDF_MAC_ADDR_SIZE] =
|
||||
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
@@ -858,6 +859,8 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
if (IS_MGMT_CIPHER(req_key->type)) {
|
||||
struct wlan_crypto_key *crypto_key = NULL;
|
||||
|
||||
@@ -875,21 +878,21 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
|
||||
|
||||
if (is_igtk(req_key->keyix)) {
|
||||
crypto_key = crypto_priv->igtk_key[igtk_idx];
|
||||
crypto_key = priv_key->igtk_key[igtk_idx];
|
||||
if (crypto_key)
|
||||
qdf_mem_free(crypto_key);
|
||||
|
||||
crypto_priv->igtk_key[igtk_idx] = key;
|
||||
crypto_priv->igtk_key_type = req_key->type;
|
||||
crypto_priv->def_igtk_tx_keyid = igtk_idx;
|
||||
priv_key->igtk_key[igtk_idx] = key;
|
||||
priv_key->igtk_key_type = req_key->type;
|
||||
priv_key->def_igtk_tx_keyid = igtk_idx;
|
||||
bigtk_idx = 0;
|
||||
} else {
|
||||
crypto_key = crypto_priv->bigtk_key[bigtk_idx];
|
||||
crypto_key = priv_key->bigtk_key[bigtk_idx];
|
||||
if (crypto_key)
|
||||
qdf_mem_free(crypto_key);
|
||||
|
||||
crypto_priv->bigtk_key[bigtk_idx] = key;
|
||||
crypto_priv->def_bigtk_tx_keyid = bigtk_idx;
|
||||
priv_key->bigtk_key[bigtk_idx] = key;
|
||||
priv_key->def_bigtk_tx_keyid = bigtk_idx;
|
||||
igtk_idx = 0;
|
||||
}
|
||||
} else {
|
||||
@@ -901,15 +904,15 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
&& (req_key->type != WLAN_CRYPTO_CIPHER_WEP)) {
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
if (!crypto_priv->key[req_key->keyix]) {
|
||||
crypto_priv->key[req_key->keyix]
|
||||
if (!priv_key->key[req_key->keyix]) {
|
||||
priv_key->key[req_key->keyix]
|
||||
= qdf_mem_malloc(
|
||||
sizeof(struct wlan_crypto_key));
|
||||
if (!crypto_priv->key[req_key->keyix])
|
||||
if (!priv_key->key[req_key->keyix])
|
||||
return QDF_STATUS_E_NOMEM;
|
||||
}
|
||||
key = crypto_priv->key[req_key->keyix];
|
||||
crypto_priv->def_tx_keyid = req_key->keyix;
|
||||
key = priv_key->key[req_key->keyix];
|
||||
priv_key->def_tx_keyid = req_key->keyix;
|
||||
}
|
||||
if (vdev_mode == QDF_STA_MODE) {
|
||||
peer = wlan_objmgr_vdev_try_get_bsspeer(vdev,
|
||||
@@ -917,13 +920,13 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
if (!peer) {
|
||||
crypto_err("peer NULL");
|
||||
if (IS_MGMT_CIPHER(req_key->type)) {
|
||||
crypto_priv->igtk_key[igtk_idx] = NULL;
|
||||
crypto_priv->bigtk_key[bigtk_idx]
|
||||
priv_key->igtk_key[igtk_idx] = NULL;
|
||||
priv_key->bigtk_key[bigtk_idx]
|
||||
= NULL;
|
||||
crypto_priv->igtk_key_type
|
||||
priv_key->igtk_key_type
|
||||
= WLAN_CRYPTO_CIPHER_NONE;
|
||||
} else
|
||||
crypto_priv->key[req_key->keyix] = NULL;
|
||||
priv_key->key[req_key->keyix] = NULL;
|
||||
if (key)
|
||||
qdf_mem_free(key);
|
||||
return QDF_STATUS_E_INVAL;
|
||||
@@ -959,6 +962,9 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
status = QDF_STATUS_E_INVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
if (IS_MGMT_CIPHER(req_key->type)) {
|
||||
struct wlan_crypto_key *crypto_key = NULL;
|
||||
|
||||
@@ -979,20 +985,20 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
}
|
||||
|
||||
if (is_igtk(req_key->keyix)) {
|
||||
crypto_key = crypto_priv->igtk_key[igtk_idx];
|
||||
crypto_key = priv_key->igtk_key[igtk_idx];
|
||||
if (crypto_key)
|
||||
qdf_mem_free(crypto_key);
|
||||
|
||||
crypto_priv->igtk_key[igtk_idx] = key;
|
||||
crypto_priv->igtk_key_type = req_key->type;
|
||||
crypto_priv->def_igtk_tx_keyid = igtk_idx;
|
||||
priv_key->igtk_key[igtk_idx] = key;
|
||||
priv_key->igtk_key_type = req_key->type;
|
||||
priv_key->def_igtk_tx_keyid = igtk_idx;
|
||||
} else {
|
||||
crypto_key = crypto_priv->bigtk_key[bigtk_idx];
|
||||
crypto_key = priv_key->bigtk_key[bigtk_idx];
|
||||
if (crypto_key)
|
||||
qdf_mem_free(crypto_key);
|
||||
|
||||
crypto_priv->bigtk_key[bigtk_idx] = key;
|
||||
crypto_priv->def_bigtk_tx_keyid = bigtk_idx;
|
||||
priv_key->bigtk_key[bigtk_idx] = key;
|
||||
priv_key->def_bigtk_tx_keyid = bigtk_idx;
|
||||
}
|
||||
} else {
|
||||
uint16_t kid = req_key->keyix;
|
||||
@@ -1003,16 +1009,16 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
status = QDF_STATUS_E_INVAL;
|
||||
goto err;
|
||||
}
|
||||
if (!crypto_priv->key[kid]) {
|
||||
crypto_priv->key[kid]
|
||||
if (!priv_key->key[kid]) {
|
||||
priv_key->key[kid]
|
||||
= qdf_mem_malloc(
|
||||
sizeof(struct wlan_crypto_key));
|
||||
if (!crypto_priv->key[kid]) {
|
||||
if (!priv_key->key[kid]) {
|
||||
status = QDF_STATUS_E_NOMEM;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
key = crypto_priv->key[kid];
|
||||
key = priv_key->key[kid];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1028,7 +1034,7 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
||||
|
||||
if (req_key->flags & WLAN_CRYPTO_KEY_DEFAULT
|
||||
&& (!IS_MGMT_CIPHER(req_key->type))) {
|
||||
crypto_priv->def_tx_keyid = key->keyix;
|
||||
crypto_priv->crypto_key.def_tx_keyid = key->keyix;
|
||||
key->flags |= WLAN_CRYPTO_KEY_DEFAULT;
|
||||
}
|
||||
if ((req_key->type == WLAN_CRYPTO_CIPHER_WAPI_SMS4)
|
||||
@@ -1157,6 +1163,7 @@ struct wlan_crypto_key *wlan_crypto_vdev_getkey(struct wlan_objmgr_vdev *vdev,
|
||||
struct wlan_crypto_comp_priv *crypto_priv;
|
||||
struct wlan_crypto_params *crypto_params;
|
||||
struct wlan_crypto_key *key = NULL;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
|
||||
crypto_params = wlan_crypto_vdev_get_comp_params(vdev, &crypto_priv);
|
||||
|
||||
@@ -1164,20 +1171,23 @@ struct wlan_crypto_key *wlan_crypto_vdev_getkey(struct wlan_objmgr_vdev *vdev,
|
||||
crypto_err("crypto_priv NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
/* for keyix 4,5 we return the igtk keys for keyix more than 5
|
||||
* we return the default key, for all other keyix we return the
|
||||
* key accordingly.
|
||||
*/
|
||||
if ((keyix == WLAN_CRYPTO_KEYIX_NONE) ||
|
||||
!is_valid_keyix(keyix))
|
||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||
key = priv_key->key[crypto_priv->crypto_key.def_tx_keyid];
|
||||
else if (is_bigtk(keyix))
|
||||
key = crypto_priv->bigtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX
|
||||
key = priv_key->bigtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX
|
||||
- WLAN_CRYPTO_MAXIGTKKEYIDX];
|
||||
else if (is_igtk(keyix))
|
||||
key = crypto_priv->igtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX];
|
||||
key = priv_key->igtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX];
|
||||
else
|
||||
key = crypto_priv->key[keyix];
|
||||
key = priv_key->key[keyix];
|
||||
|
||||
if (key && key->valid)
|
||||
return key;
|
||||
@@ -1192,6 +1202,7 @@ struct wlan_crypto_key *wlan_crypto_peer_getkey(struct wlan_objmgr_peer *peer,
|
||||
struct wlan_crypto_comp_priv *crypto_priv;
|
||||
struct wlan_crypto_params *crypto_params;
|
||||
struct wlan_crypto_key *key = NULL;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
|
||||
crypto_params = wlan_crypto_peer_get_comp_params(peer, &crypto_priv);
|
||||
|
||||
@@ -1200,20 +1211,22 @@ struct wlan_crypto_key *wlan_crypto_peer_getkey(struct wlan_objmgr_peer *peer,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
/* for keyix 4,5 we return the igtk keys for keyix more than 5
|
||||
* we return the default key, for all other keyix we return the
|
||||
* key accordingly.
|
||||
*/
|
||||
if (keyix == WLAN_CRYPTO_KEYIX_NONE ||
|
||||
!is_valid_keyix(keyix))
|
||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||
key = priv_key->key[crypto_priv->crypto_key.def_tx_keyid];
|
||||
else if (is_bigtk(keyix))
|
||||
key = crypto_priv->bigtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX
|
||||
key = priv_key->bigtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX
|
||||
- WLAN_CRYPTO_MAXIGTKKEYIDX];
|
||||
else if (is_igtk(keyix))
|
||||
key = crypto_priv->igtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX];
|
||||
key = priv_key->igtk_key[keyix - WLAN_CRYPTO_MAXKEYIDX];
|
||||
else
|
||||
key = crypto_priv->key[keyix];
|
||||
key = priv_key->key[keyix];
|
||||
|
||||
if (key && key->valid)
|
||||
return key;
|
||||
@@ -1430,17 +1443,17 @@ QDF_STATUS wlan_crypto_delkey(struct wlan_objmgr_vdev *vdev,
|
||||
goto ret_rel_ref;
|
||||
}
|
||||
if (is_igtk(key_idx)) {
|
||||
key = crypto_priv->igtk_key[igtk_idx];
|
||||
crypto_priv->igtk_key[igtk_idx] = NULL;
|
||||
key = crypto_priv->crypto_key.igtk_key[igtk_idx];
|
||||
crypto_priv->crypto_key.igtk_key[igtk_idx] = NULL;
|
||||
} else {
|
||||
key = crypto_priv->bigtk_key[bigtk_idx];
|
||||
crypto_priv->bigtk_key[bigtk_idx] = NULL;
|
||||
key = crypto_priv->crypto_key.bigtk_key[bigtk_idx];
|
||||
crypto_priv->crypto_key.bigtk_key[bigtk_idx] = NULL;
|
||||
}
|
||||
if (key)
|
||||
key->valid = 0;
|
||||
} else {
|
||||
key = crypto_priv->key[key_idx];
|
||||
crypto_priv->key[key_idx] = NULL;
|
||||
key = crypto_priv->crypto_key.key[key_idx];
|
||||
crypto_priv->crypto_key.key[key_idx] = NULL;
|
||||
}
|
||||
|
||||
if (!key) {
|
||||
@@ -1549,7 +1562,7 @@ QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[key_idx];
|
||||
key = crypto_priv->crypto_key.key[key_idx];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
} else {
|
||||
@@ -1576,7 +1589,7 @@ QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[key_idx];
|
||||
key = crypto_priv->crypto_key.key[key_idx];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
@@ -1586,7 +1599,7 @@ QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev,
|
||||
if (wlan_crypto_set_default_key(vdev, key_idx, macaddr) !=
|
||||
QDF_STATUS_SUCCESS)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
crypto_priv->def_tx_keyid = key_idx;
|
||||
crypto_priv->crypto_key.def_tx_keyid = key_idx;
|
||||
|
||||
return QDF_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1599,6 +1612,7 @@ QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev,
|
||||
struct wlan_crypto_comp_priv *crypto_priv;
|
||||
struct wlan_crypto_params *crypto_params;
|
||||
struct wlan_crypto_key *key;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
QDF_STATUS status;
|
||||
struct wlan_crypto_cipher *cipher_table;
|
||||
struct wlan_objmgr_psoc *psoc;
|
||||
@@ -1642,7 +1656,9 @@ QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
key = priv_key->key[priv_key->def_tx_keyid];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
|
||||
@@ -1654,6 +1670,7 @@ QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev,
|
||||
crypto_err("crypto_priv NULL");
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
crypto_params = wlan_crypto_peer_get_comp_params(peer,
|
||||
&crypto_priv);
|
||||
|
||||
@@ -1663,7 +1680,9 @@ QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev,
|
||||
goto err;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
key = priv_key->key[priv_key->def_tx_keyid];
|
||||
if (!key) {
|
||||
crypto_err("Key is NULL");
|
||||
status = QDF_STATUS_E_INVAL;
|
||||
@@ -1752,7 +1771,7 @@ QDF_STATUS wlan_crypto_decap(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[keyid];
|
||||
key = crypto_priv->crypto_key.key[keyid];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
} else {
|
||||
@@ -1773,7 +1792,7 @@ QDF_STATUS wlan_crypto_decap(struct wlan_objmgr_vdev *vdev,
|
||||
goto err;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[keyid];
|
||||
key = crypto_priv->crypto_key.key[keyid];
|
||||
if (!key) {
|
||||
crypto_err("Key is NULL");
|
||||
status = QDF_STATUS_E_INVAL;
|
||||
@@ -1806,6 +1825,7 @@ QDF_STATUS wlan_crypto_enmic(struct wlan_objmgr_vdev *vdev,
|
||||
struct wlan_crypto_comp_priv *crypto_priv;
|
||||
struct wlan_crypto_params *crypto_params;
|
||||
struct wlan_crypto_key *key;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
QDF_STATUS status;
|
||||
struct wlan_crypto_cipher *cipher_table;
|
||||
struct wlan_objmgr_psoc *psoc;
|
||||
@@ -1835,7 +1855,9 @@ QDF_STATUS wlan_crypto_enmic(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
key = priv_key->key[crypto_priv->crypto_key.def_tx_keyid];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
|
||||
@@ -1862,7 +1884,9 @@ QDF_STATUS wlan_crypto_enmic(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
key = priv_key->key[crypto_priv->crypto_key.def_tx_keyid];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
@@ -1922,7 +1946,7 @@ QDF_STATUS wlan_crypto_demic(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[keyid];
|
||||
key = crypto_priv->crypto_key.key[keyid];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
|
||||
@@ -1949,7 +1973,7 @@ QDF_STATUS wlan_crypto_demic(struct wlan_objmgr_vdev *vdev,
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
|
||||
key = crypto_priv->key[keyid];
|
||||
key = crypto_priv->crypto_key.key[keyid];
|
||||
if (!key)
|
||||
return QDF_STATUS_E_INVAL;
|
||||
}
|
||||
@@ -2075,6 +2099,7 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
||||
uint32_t len)
|
||||
{
|
||||
struct wlan_crypto_key *key;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
struct wlan_crypto_mmie *mmie;
|
||||
uint8_t *pn, *aad, *buf, *efrm, nonce[12];
|
||||
struct wlan_frame_hdr *hdr;
|
||||
@@ -2096,18 +2121,20 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (crypto_priv->def_igtk_tx_keyid >= WLAN_CRYPTO_MAXIGTKKEYIDX) {
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
if (priv_key->def_igtk_tx_keyid >= WLAN_CRYPTO_MAXIGTKKEYIDX) {
|
||||
crypto_err("igtk key invalid keyid %d",
|
||||
crypto_priv->def_igtk_tx_keyid);
|
||||
priv_key->def_igtk_tx_keyid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
key = crypto_priv->igtk_key[crypto_priv->def_igtk_tx_keyid];
|
||||
key = priv_key->igtk_key[priv_key->def_igtk_tx_keyid];
|
||||
if (!key) {
|
||||
crypto_err("No igtk key present");
|
||||
return NULL;
|
||||
}
|
||||
mic_len = (crypto_priv->igtk_key_type
|
||||
mic_len = (priv_key->igtk_key_type
|
||||
== WLAN_CRYPTO_CIPHER_AES_CMAC) ? 8 : 16;
|
||||
|
||||
efrm = bfrm + len;
|
||||
@@ -2121,7 +2148,7 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
||||
mmie->length = sizeof(*mmie) - 2;
|
||||
mmie->key_id = qdf_cpu_to_le16(key->keyix);
|
||||
|
||||
mic_len = (crypto_priv->igtk_key_type
|
||||
mic_len = (priv_key->igtk_key_type
|
||||
== WLAN_CRYPTO_CIPHER_AES_CMAC) ? 8 : 16;
|
||||
if (mic_len == 8) {
|
||||
mmie->length -= 8;
|
||||
@@ -2165,19 +2192,19 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
||||
*/
|
||||
|
||||
qdf_mem_copy(buf + aad_len, bfrm + hdrlen, len - hdrlen);
|
||||
if (crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_CMAC) {
|
||||
if (priv_key->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_CMAC) {
|
||||
|
||||
ret = omac1_aes_128(key->keyval, buf,
|
||||
len + aad_len - hdrlen, mic);
|
||||
qdf_mem_copy(mmie->mic, mic, 8);
|
||||
|
||||
} else if (crypto_priv->igtk_key_type
|
||||
} else if (priv_key->igtk_key_type
|
||||
== WLAN_CRYPTO_CIPHER_AES_CMAC_256) {
|
||||
|
||||
ret = omac1_aes_256(key->keyval, buf,
|
||||
len + aad_len - hdrlen, mmie->mic);
|
||||
} else if ((crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_GMAC)
|
||||
|| (crypto_priv->igtk_key_type
|
||||
} else if ((priv_key->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_GMAC) ||
|
||||
(priv_key->igtk_key_type
|
||||
== WLAN_CRYPTO_CIPHER_AES_GMAC_256)) {
|
||||
|
||||
qdf_mem_copy(nonce, hdr->i_addr2, QDF_MAC_ADDR_SIZE);
|
||||
@@ -2203,6 +2230,7 @@ bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
|
||||
struct wlan_crypto_mmie *mmie = NULL;
|
||||
uint8_t *ipn, *aad, *buf, *mic, nonce[12];
|
||||
struct wlan_crypto_key *key;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
struct wlan_frame_hdr *hdr;
|
||||
uint16_t mic_len, hdrlen, len;
|
||||
struct wlan_crypto_comp_priv *crypto_priv;
|
||||
@@ -2224,10 +2252,12 @@ bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
|
||||
return false;
|
||||
}
|
||||
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
crypto_params = &(crypto_priv->crypto_params);
|
||||
|
||||
|
||||
mic_len = (crypto_priv->igtk_key_type
|
||||
mic_len = (priv_key->igtk_key_type
|
||||
== WLAN_CRYPTO_CIPHER_AES_CMAC) ? 8 : 16;
|
||||
hdrlen = sizeof(struct wlan_frame_hdr);
|
||||
|
||||
@@ -2250,7 +2280,7 @@ bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
|
||||
return false;
|
||||
}
|
||||
|
||||
key = crypto_priv->igtk_key[mmie->key_id - WLAN_CRYPTO_MAXKEYIDX];
|
||||
key = priv_key->igtk_key[mmie->key_id - WLAN_CRYPTO_MAXKEYIDX];
|
||||
if (!key) {
|
||||
crypto_err("No igtk key present");
|
||||
return false;
|
||||
@@ -2301,15 +2331,15 @@ bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
|
||||
qdf_mem_free(buf);
|
||||
return false;
|
||||
}
|
||||
if (crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_CMAC) {
|
||||
if (priv_key->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_CMAC) {
|
||||
ret = omac1_aes_128(key->keyval, buf,
|
||||
len - hdrlen + aad_len, mic);
|
||||
} else if (crypto_priv->igtk_key_type
|
||||
} else if (priv_key->igtk_key_type
|
||||
== WLAN_CRYPTO_CIPHER_AES_CMAC_256) {
|
||||
ret = omac1_aes_256(key->keyval, buf,
|
||||
len + aad_len - hdrlen, mic);
|
||||
} else if ((crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_GMAC)
|
||||
|| (crypto_priv->igtk_key_type
|
||||
} else if ((priv_key->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_GMAC) ||
|
||||
(priv_key->igtk_key_type
|
||||
== WLAN_CRYPTO_CIPHER_AES_GMAC_256)) {
|
||||
qdf_mem_copy(nonce, hdr->i_addr2, QDF_MAC_ADDR_SIZE);
|
||||
wlan_crypto_gmac_pn_swap(nonce + 6, ipn);
|
||||
@@ -3423,6 +3453,7 @@ QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev,
|
||||
struct wlan_crypto_params *crypto_params;
|
||||
struct wlan_crypto_key *key;
|
||||
struct wlan_crypto_key *sta_key;
|
||||
struct wlan_crypto_keys *sta_priv = NULL;
|
||||
struct wlan_crypto_cipher *cipher_table;
|
||||
struct wlan_objmgr_psoc *psoc;
|
||||
struct wlan_lmac_if_tx_ops *tx_ops;
|
||||
@@ -3477,9 +3508,11 @@ QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
sta_priv = &sta_crypto_priv->crypto_key;
|
||||
|
||||
for (i = 0; i < WLAN_CRYPTO_MAXKEYIDX; i++) {
|
||||
if (crypto_priv->key[i]) {
|
||||
key = crypto_priv->key[i];
|
||||
if (crypto_priv->crypto_key.key[i]) {
|
||||
key = crypto_priv->crypto_key.key[i];
|
||||
if (!key || !key->valid)
|
||||
continue;
|
||||
|
||||
@@ -3502,17 +3535,17 @@ QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
sta_crypto_priv->key[i] = sta_key;
|
||||
sta_priv->key[i] = sta_key;
|
||||
qdf_mem_copy(sta_key, key,
|
||||
sizeof(struct wlan_crypto_key));
|
||||
|
||||
sta_key->flags &= ~WLAN_CRYPTO_KEY_DEFAULT;
|
||||
|
||||
if (crypto_priv->def_tx_keyid == i) {
|
||||
if (crypto_priv->crypto_key.def_tx_keyid == i) {
|
||||
sta_key->flags
|
||||
|= WLAN_CRYPTO_KEY_DEFAULT;
|
||||
sta_crypto_priv->def_tx_keyid =
|
||||
crypto_priv->def_tx_keyid;
|
||||
sta_priv->def_tx_keyid =
|
||||
crypto_priv->crypto_key.def_tx_keyid;
|
||||
}
|
||||
/* setting the broadcast/multicast key for sta*/
|
||||
if (opmode == QDF_STA_MODE ||
|
||||
@@ -3829,7 +3862,7 @@ static void crypto_plumb_peer_keys(struct wlan_objmgr_vdev *vdev,
|
||||
}
|
||||
|
||||
for (i = 0; i < WLAN_CRYPTO_MAXKEYIDX; i++) {
|
||||
key = crypto_priv->key[i];
|
||||
key = crypto_priv->crypto_key.key[i];
|
||||
if (key && key->valid) {
|
||||
tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
|
||||
|
||||
@@ -3887,7 +3920,7 @@ void wlan_crypto_restore_keys(struct wlan_objmgr_vdev *vdev)
|
||||
crypto_err("crypto_priv is NULL");
|
||||
return;
|
||||
}
|
||||
key = crypto_priv->key[i];
|
||||
key = crypto_priv->crypto_key.key[i];
|
||||
if (key && key->valid) {
|
||||
tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
|
||||
if (!tx_ops) {
|
||||
@@ -4168,9 +4201,9 @@ int8_t wlan_crypto_get_default_key_idx(struct wlan_objmgr_vdev *vdev, bool igtk)
|
||||
}
|
||||
|
||||
if (igtk)
|
||||
return crypto_priv->def_igtk_tx_keyid;
|
||||
return crypto_priv->crypto_key.def_igtk_tx_keyid;
|
||||
else
|
||||
return crypto_priv->def_tx_keyid;
|
||||
return crypto_priv->crypto_key.def_tx_keyid;
|
||||
}
|
||||
|
||||
enum wlan_crypto_cipher_type
|
||||
@@ -4230,28 +4263,32 @@ QDF_STATUS wlan_crypto_save_key(struct wlan_objmgr_vdev *vdev,
|
||||
struct wlan_crypto_key *crypto_key)
|
||||
{
|
||||
struct wlan_crypto_comp_priv *crypto_priv;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
|
||||
crypto_priv = wlan_get_vdev_crypto_obj(vdev);
|
||||
if (!crypto_priv) {
|
||||
crypto_err("crypto_priv NULL");
|
||||
return QDF_STATUS_E_FAILURE;
|
||||
}
|
||||
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
if (!is_valid_keyix(key_index)) {
|
||||
crypto_err("Invalid Key index %d", key_index);
|
||||
return QDF_STATUS_E_FAILURE;
|
||||
}
|
||||
if (key_index < WLAN_CRYPTO_MAXKEYIDX) {
|
||||
crypto_priv->key[key_index] = crypto_key;
|
||||
priv_key->key[key_index] = crypto_key;
|
||||
} else if (is_igtk(key_index)) {
|
||||
crypto_priv->igtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX] =
|
||||
priv_key->igtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX] =
|
||||
crypto_key;
|
||||
crypto_priv->def_igtk_tx_keyid =
|
||||
priv_key->def_igtk_tx_keyid =
|
||||
key_index - WLAN_CRYPTO_MAXKEYIDX;
|
||||
crypto_priv->igtk_key_type = crypto_key->cipher_type;
|
||||
priv_key->igtk_key_type = crypto_key->cipher_type;
|
||||
} else {
|
||||
crypto_priv->bigtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX
|
||||
priv_key->bigtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX
|
||||
- WLAN_CRYPTO_MAXIGTKKEYIDX] = crypto_key;
|
||||
crypto_priv->def_bigtk_tx_keyid =
|
||||
priv_key->def_bigtk_tx_keyid =
|
||||
key_index - WLAN_CRYPTO_MAXKEYIDX
|
||||
- WLAN_CRYPTO_MAXIGTKKEYIDX;
|
||||
}
|
||||
@@ -4264,22 +4301,26 @@ struct wlan_crypto_key *wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev,
|
||||
uint8_t key_index)
|
||||
{
|
||||
struct wlan_crypto_comp_priv *crypto_priv;
|
||||
struct wlan_crypto_keys *priv_key = NULL;
|
||||
|
||||
crypto_priv = wlan_get_vdev_crypto_obj(vdev);
|
||||
if (!crypto_priv) {
|
||||
crypto_err("crypto_priv NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
priv_key = &crypto_priv->crypto_key;
|
||||
|
||||
if (!is_valid_keyix(key_index)) {
|
||||
crypto_err("Invalid Key index %d", key_index);
|
||||
return NULL;
|
||||
}
|
||||
if (key_index < WLAN_CRYPTO_MAXKEYIDX)
|
||||
return crypto_priv->key[key_index];
|
||||
return priv_key->key[key_index];
|
||||
else if (is_igtk(key_index))
|
||||
return crypto_priv->igtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX];
|
||||
return priv_key->igtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX];
|
||||
else
|
||||
return crypto_priv->bigtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX
|
||||
return priv_key->bigtk_key[key_index - WLAN_CRYPTO_MAXKEYIDX
|
||||
- WLAN_CRYPTO_MAXIGTKKEYIDX];
|
||||
|
||||
return NULL;
|
||||
|
@@ -183,29 +183,29 @@ static void wlan_crypto_free_key(struct wlan_crypto_comp_priv *crypto_priv)
|
||||
}
|
||||
|
||||
for (i = 0; i < WLAN_CRYPTO_MAX_VLANKEYIX; i++) {
|
||||
if (crypto_priv->key[i]) {
|
||||
qdf_mem_free(crypto_priv->key[i]);
|
||||
crypto_priv->key[i] = NULL;
|
||||
if (crypto_priv->crypto_key.key[i]) {
|
||||
qdf_mem_free(crypto_priv->crypto_key.key[i]);
|
||||
crypto_priv->crypto_key.key[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < WLAN_CRYPTO_MAXIGTKKEYIDX; i++) {
|
||||
if (crypto_priv->igtk_key[i]) {
|
||||
qdf_mem_free(crypto_priv->igtk_key[i]);
|
||||
crypto_priv->igtk_key[i] = NULL;
|
||||
if (crypto_priv->crypto_key.igtk_key[i]) {
|
||||
qdf_mem_free(crypto_priv->crypto_key.igtk_key[i]);
|
||||
crypto_priv->crypto_key.igtk_key[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < WLAN_CRYPTO_MAXBIGTKKEYIDX; i++) {
|
||||
if (crypto_priv->bigtk_key[i]) {
|
||||
qdf_mem_free(crypto_priv->bigtk_key[i]);
|
||||
crypto_priv->bigtk_key[i] = NULL;
|
||||
if (crypto_priv->crypto_key.bigtk_key[i]) {
|
||||
qdf_mem_free(crypto_priv->crypto_key.bigtk_key[i]);
|
||||
crypto_priv->crypto_key.bigtk_key[i] = NULL;
|
||||
}
|
||||
}
|
||||
/* Reset All key index as well */
|
||||
crypto_priv->def_tx_keyid = 0;
|
||||
crypto_priv->def_igtk_tx_keyid = 0;
|
||||
crypto_priv->def_bigtk_tx_keyid = 0;
|
||||
crypto_priv->crypto_key.def_tx_keyid = 0;
|
||||
crypto_priv->crypto_key.def_igtk_tx_keyid = 0;
|
||||
crypto_priv->crypto_key.def_bigtk_tx_keyid = 0;
|
||||
}
|
||||
|
||||
#ifdef CRYPTO_SET_KEY_CONVERGED
|
||||
|
Reference in New Issue
Block a user