From patchwork Wed Jul 13 17:50:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 972842 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6DHoeh9019403 for ; Wed, 13 Jul 2011 17:50:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965405Ab1GMRui (ORCPT ); Wed, 13 Jul 2011 13:50:38 -0400 Received: from he.sipsolutions.net ([78.46.109.217]:58716 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965400Ab1GMRui (ORCPT ); Wed, 13 Jul 2011 13:50:38 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1Qh3Zz-00015U-MI; Wed, 13 Jul 2011 19:50:35 +0200 Subject: [PATCH] mac80211: allow driver access to TKIP RX P1K From: Johannes Berg To: John Linville Cc: linux-wireless Date: Wed, 13 Jul 2011 19:50:34 +0200 Message-ID: <1310579434.3873.11.camel@jlt3.sipsolutions.net> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 13 Jul 2011 17:50:41 +0000 (UTC) From: Johannes Berg 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 --- include/net/mac80211.h | 14 ++++++++++++++ net/mac80211/tkip.c | 11 +++++++++++ 2 files changed, 25 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/include/net/mac80211.h 2011-07-13 19:20:36.000000000 +0200 +++ b/include/net/mac80211.h 2011-07-13 19:24:20.000000000 +0200 @@ -2612,6 +2612,20 @@ static inline void ieee80211_get_tkip_p1 } /** + * 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 * * This function computes the TKIP RC4 key for the IV values --- a/net/mac80211/tkip.c 2011-07-13 19:20:36.000000000 +0200 +++ b/net/mac80211/tkip.c 2011-07-13 19:20:37.000000000 +0200 @@ -185,6 +185,17 @@ void ieee80211_get_tkip_p1k_iv(struct ie } 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) {