mac80211: allow driver access to TKIP RX P1K
authorJohannes Berg <johannes.berg@intel.com>
Wed, 13 Jul 2011 17:50:34 +0000 (19:50 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 15 Jul 2011 17:38:32 +0000 (13:38 -0400)
When the driver wants to pre-program the TKIP
RX phase 1 key, it needs to be able to obtain
it for the peer's TA. Add API to allow it to
generate it.

The generation uses a dummy on-stack context
since it doesn't know the RX queue.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/net/mac80211.h
net/mac80211/tkip.c

index ea2c8c3..9e91b4f 100644 (file)
@@ -2612,6 +2612,20 @@ static inline void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
        ieee80211_get_tkip_p1k_iv(keyconf, iv32, p1k);
 }
 
+/**
+ * ieee80211_get_tkip_rx_p1k - get a TKIP phase 1 key for RX
+ *
+ * This function returns the TKIP phase 1 key for the given IV32
+ * and transmitter address.
+ *
+ * @keyconf: the parameter passed with the set key
+ * @ta: TA that will be used with the key
+ * @iv32: IV32 to get the P1K for
+ * @p1k: a buffer to which the key will be written, as 5 u16 values
+ */
+void ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
+                              const u8 *ta, u32 iv32, u16 *p1k);
+
 /**
  * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
  *
index cc79e69..f49d00a 100644 (file)
@@ -185,6 +185,17 @@ void ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *keyconf,
 }
 EXPORT_SYMBOL(ieee80211_get_tkip_p1k_iv);
 
+void ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
+                               const u8 *ta, u32 iv32, u16 *p1k)
+{
+       const u8 *tk = &keyconf->key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
+       struct tkip_ctx ctx;
+
+       tkip_mixing_phase1(tk, &ctx, ta, iv32);
+       memcpy(p1k, ctx.p1k, sizeof(ctx.p1k));
+}
+EXPORT_SYMBOL(ieee80211_get_tkip_rx_p1k);
+
 void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
                            struct sk_buff *skb, u8 *p2k)
 {