Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c014420 authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville
Browse files

mac80211: Replace ieee80211_tx_control->key_idx with ieee80211_key_conf



The hw_key_idx inside the ieee80211_key_conf structure does
not provide all the information drivers might need to perform
hardware encryption.

This is in particular true for rt2x00 who needs to know the
key algorithm and whether it is a shared or pairwise key.

By passing the ieee80211_key_conf pointer it assures us that
drivers can make full use of all information that it should know
about a particular key.

Additionally this patch updates all drivers to grab the hw_key_idx from
the ieee80211_key_conf structure.

v2: Removed bogus u16 cast
v3: Add warning about ieee80211_tx_control pointers
v4: Update warning about ieee80211_tx_control pointers

Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Acked-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 6f4083aa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1319,7 +1319,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
	pktlen = skb->len;

	if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) {
		keyidx = ctl->key_idx;
		keyidx = ctl->hw_key->hw_key_idx;
		pktlen += ctl->icv_len;
	}

+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,

	plcp_fragment_len = fragment_len + FCS_LEN;
	if (use_encryption) {
		u8 key_idx = (u16) (txctl->key_idx);
		u8 key_idx = txctl->hw_key->hw_key_idx;
		struct b43_key *key;
		int wlhdr_len;
		size_t iv_len;
+1 −1
Original line number Diff line number Diff line
@@ -232,7 +232,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,

	plcp_fragment_len = fragment_len + FCS_LEN;
	if (use_encryption) {
		u8 key_idx = (u16)(txctl->key_idx);
		u8 key_idx = txctl->hw_key->hw_key_idx;
		struct b43legacy_key *key;
		int wlhdr_len;
		size_t iv_len;
+4 −3
Original line number Diff line number Diff line
@@ -2391,7 +2391,8 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
				      struct sk_buff *skb_frag,
				      int last_frag)
{
	struct iwl3945_hw_key *keyinfo = &priv->stations[ctl->key_idx].keyinfo;
	struct iwl3945_hw_key *keyinfo =
	    &priv->stations[ctl->hw_key->hw_key_idx].keyinfo;

	switch (keyinfo->alg) {
	case ALG_CCMP:
@@ -2414,7 +2415,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,

	case ALG_WEP:
		cmd->cmd.tx.sec_ctl = TX_CMD_SEC_WEP |
		    (ctl->key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT;
		    (ctl->hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT;

		if (keyinfo->keylen == 13)
			cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128;
@@ -2422,7 +2423,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
		memcpy(&cmd->cmd.tx.key[3], keyinfo->key, keyinfo->keylen);

		IWL_DEBUG_TX("Configuring packet for WEP encryption "
			     "with key %d\n", ctl->key_idx);
			     "with key %d\n", ctl->hw_key->hw_key_idx);
		break;

	default:
+3 −3
Original line number Diff line number Diff line
@@ -1926,7 +1926,7 @@ static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
	struct iwl_wep_key *wepkey;
	int keyidx = 0;

	BUG_ON(ctl->key_idx > 3);
	BUG_ON(ctl->hw_key->hw_key_idx > 3);

	switch (keyinfo->alg) {
	case ALG_CCMP:
@@ -1945,11 +1945,11 @@ static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
		break;

	case ALG_WEP:
		wepkey = &priv->wep_keys[ctl->key_idx];
		wepkey = &priv->wep_keys[ctl->hw_key->hw_key_idx];
		cmd->cmd.tx.sec_ctl = 0;
		if (priv->default_wep_key) {
			/* the WEP key was sent as static */
			keyidx = ctl->key_idx;
			keyidx = ctl->hw_key->hw_key_idx;
			memcpy(&cmd->cmd.tx.key[3], wepkey->key,
							wepkey->key_size);
			if (wepkey->key_size == WEP_KEY_LEN_128)
Loading