Skip to content

Commit

Permalink
mac80211: extend get_key() to return PN for all ciphers
Browse files Browse the repository at this point in the history
For ciphers not supported by mac80211, the function currently
doesn't return any PN data. Fix this by extending the driver's
get_key_seq() a little more to allow moving arbitrary PN data.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed May 6, 2015
1 parent 9352c19 commit a31cf1c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,8 @@ struct ieee80211_key_conf {
u8 key[0];
};

#define IEEE80211_MAX_PN_LEN 16

/**
* struct ieee80211_key_seq - key sequence counter
*
Expand All @@ -1513,6 +1515,7 @@ struct ieee80211_key_conf {
* reverse order than in packet)
* @gcmp: PN data, most significant byte first (big endian,
* reverse order than in packet)
* @hw: data for HW-only (e.g. cipher scheme) keys
*/
struct ieee80211_key_seq {
union {
Expand All @@ -1532,6 +1535,10 @@ struct ieee80211_key_seq {
struct {
u8 pn[6];
} gcmp;
struct {
u8 seq[IEEE80211_MAX_PN_LEN];
u8 seq_len;
} hw;
};
};

Expand Down
9 changes: 9 additions & 0 deletions net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,15 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
params.seq = seq;
params.seq_len = 6;
break;
default:
if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
break;
if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
break;
drv_get_key_seq(sdata->local, key, &kseq);
params.seq = kseq.hw.seq;
params.seq_len = kseq.hw.seq_len;
break;
}

params.key = key->conf.key;
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
break;
default:
if (cs) {
size_t len = (seq_len > MAX_PN_LEN) ?
MAX_PN_LEN : seq_len;
size_t len = (seq_len > IEEE80211_MAX_PN_LEN) ?
IEEE80211_MAX_PN_LEN : seq_len;

key->conf.iv_len = cs->hdr_len;
key->conf.icv_len = cs->mic_len;
Expand Down
3 changes: 1 addition & 2 deletions net/mac80211/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#define NUM_DEFAULT_KEYS 4
#define NUM_DEFAULT_MGMT_KEYS 2
#define MAX_PN_LEN 16

struct ieee80211_local;
struct ieee80211_sub_if_data;
Expand Down Expand Up @@ -116,7 +115,7 @@ struct ieee80211_key {
} gcmp;
struct {
/* generic cipher scheme */
u8 rx_pn[IEEE80211_NUM_TIDS + 1][MAX_PN_LEN];
u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_MAX_PN_LEN];
} gen;
} u;

Expand Down

0 comments on commit a31cf1c

Please sign in to comment.