Skip to content

Commit

Permalink
install mgtk TX key once on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
twpedersen committed Dec 12, 2011
1 parent 91f747f commit 7ba0882
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
8 changes: 0 additions & 8 deletions ampe.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,9 @@
#define MESH_SECURITY_INCONSISTENT_PARAMS 59
#define MESH_SECURITY_INVALID_CAPABILITY 60

static unsigned char meshid[32];
static unsigned char meshid_len;
static unsigned char mgtk_tx[16];
static struct ampe_config config;
static const unsigned char akm_suite_selector[4] = { 0x0, 0xf, 0xac, 0x8 }; /* SAE */
static const unsigned char pw_suite_selector[4] = { 0x0, 0xf, 0xac, 0x4 }; /* CCMP */
static const unsigned char null_nonce[32] = { 0 };
static unsigned char *sta_fixed_ies;
static unsigned char sta_fixed_ies_len;

/* For debugging use */
static const char *mplstates[] = {
Expand Down Expand Up @@ -637,7 +631,6 @@ static void fsm_step(struct candidate *cand, enum plink_event event)
derive_mtk(cand);
estab_peer_link(cand->peer_mac,
cand->mtk, sizeof(cand->mtk),
mgtk_tx, sizeof(mgtk_tx),
cand->mgtk, sizeof(cand->mgtk),
cand->mgtk_expiration,
cand->sup_rates,
Expand Down Expand Up @@ -669,7 +662,6 @@ static void fsm_step(struct candidate *cand, enum plink_event event)
cand->link_state = PLINK_ESTAB;
estab_peer_link(cand->peer_mac,
cand->mtk, sizeof(cand->mtk),
mgtk_tx, sizeof(mgtk_tx),
cand->mgtk, sizeof(cand->mgtk),
cand->mgtk_expiration, cand->sup_rates,
cand->sup_rates_len,
Expand Down
10 changes: 8 additions & 2 deletions ampe.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#ifndef __AMPE_H
#define __AMPE_H

unsigned char meshid[32];
unsigned char meshid_len;
unsigned char mgtk_tx[16];
struct ampe_config config;
unsigned char *sta_fixed_ies;
unsigned char sta_fixed_ies_len;

enum plink_state {
PLINK_LISTEN,
PLINK_OPN_SNT,
Expand All @@ -27,8 +34,7 @@ int start_peer_link(unsigned char *peer_mac, unsigned char *me, void *cookie);

/* and implements these: */
void estab_peer_link(unsigned char *peer, unsigned char *mtk,
int mtk_len, unsigned char *mgtk, int mgtk_len,
unsigned char *peer_mgtk, int peer_mgtk_len,
int mtk_len, unsigned char *peer_mgtk, int peer_mgtk_len,
unsigned int mgtk_expiration,
unsigned char *sup_rates,
unsigned short sup_rates_len,
Expand Down
14 changes: 6 additions & 8 deletions linux/meshd-nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,6 @@ static int join_mesh_rsn(struct netlink_config_s *nlcfg, char *mesh_id, int mesh

void estab_peer_link(unsigned char *peer,
unsigned char *mtk, int mtk_len,
unsigned char *mgtk, int mgtk_len,
unsigned char *peer_mgtk, int peer_mgtk_len,
unsigned int mgtk_expiration,
unsigned char *rates,
Expand All @@ -914,7 +913,7 @@ void estab_peer_link(unsigned char *peer,
{
assert(cookie == &nlcfg);

assert(mtk_len == 16 && mgtk_len == 16 && peer_mgtk_len == 16);
assert(mtk_len == 16 && peer_mgtk_len == 16);

if (peer) {
sae_debug(MESHD_DEBUG, "estab with " MACSTR "\n", MAC2STR(peer));
Expand All @@ -925,12 +924,6 @@ void estab_peer_link(unsigned char *peer,
/* key to encrypt/decrypt unicast data AND mgmt traffic to/from this peer */
install_key(&nlcfg, peer, CIPHER_CCMP, NL80211_KEYTYPE_PAIRWISE, 0, mtk);

/* key to protect integrity of multicast mgmt frames tx*/
install_key(&nlcfg, NULL, CIPHER_AES_CMAC, NL80211_KEYTYPE_GROUP, 4, mgtk);

/* key to encrypt multicast data traffic */
install_key(&nlcfg, NULL, CIPHER_CCMP, NL80211_KEYTYPE_GROUP, 0, mgtk);

/* key to decrypt multicast data traffic from this peer */
install_key(&nlcfg, peer, CIPHER_CCMP, NL80211_KEYTYPE_GROUP, 0, peer_mgtk);

Expand Down Expand Up @@ -1239,6 +1232,11 @@ int main(int argc, char *argv[])
goto out;
}

/* key to protect integrity of multicast mgmt frames tx*/
install_key(&nlcfg, NULL, CIPHER_AES_CMAC, NL80211_KEYTYPE_GROUP, 4, mgtk_tx);
/* key to encrypt multicast data traffic */
install_key(&nlcfg, NULL, CIPHER_CCMP, NL80211_KEYTYPE_GROUP, 0, mgtk_tx);

get_wiphy(&nlcfg);

srv_main_loop(srvctx);
Expand Down

0 comments on commit 7ba0882

Please sign in to comment.