From 696f792320b9a082d28eba4e97ccc4cdab09b8b8 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 18 Jun 2016 14:39:43 +0300 Subject: [PATCH] mesh: Support variable length TX MGTK This is an initial step in supporting multiple cipher suites. Signed-off-by: Jouni Malinen --- wpa_supplicant/mesh_rsn.c | 8 ++++++-- wpa_supplicant/mesh_rsn.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/mesh_rsn.c b/wpa_supplicant/mesh_rsn.c index d7a811548..021b7d238 100644 --- a/wpa_supplicant/mesh_rsn.c +++ b/wpa_supplicant/mesh_rsn.c @@ -173,7 +173,8 @@ static int __mesh_rsn_auth_init(struct mesh_rsn *rsn, const u8 *addr, } /* TODO: support rekeying */ - if (random_get_bytes(rsn->mgtk, 16) < 0) + rsn->mgtk_len = wpa_cipher_key_len(WPA_CIPHER_CCMP); + if (random_get_bytes(rsn->mgtk, rsn->mgtk_len) < 0) return -1; /* group mgmt */ @@ -181,8 +182,10 @@ static int __mesh_rsn_auth_init(struct mesh_rsn *rsn, const u8 *addr, seq, sizeof(seq), rsn->mgtk, sizeof(rsn->mgtk)); /* group privacy / data frames */ + wpa_hexdump_key(MSG_DEBUG, "mesh: Own TX MGTK", + rsn->mgtk, rsn->mgtk_len); wpa_drv_set_key(rsn->wpa_s, WPA_ALG_CCMP, NULL, 1, 1, - seq, sizeof(seq), rsn->mgtk, sizeof(rsn->mgtk)); + seq, sizeof(seq), rsn->mgtk, rsn->mgtk_len); return 0; } @@ -191,6 +194,7 @@ static int __mesh_rsn_auth_init(struct mesh_rsn *rsn, const u8 *addr, static void mesh_rsn_deinit(struct mesh_rsn *rsn) { os_memset(rsn->mgtk, 0, sizeof(rsn->mgtk)); + rsn->mgtk_len = 0; if (rsn->auth) wpa_deinit(rsn->auth); } diff --git a/wpa_supplicant/mesh_rsn.h b/wpa_supplicant/mesh_rsn.h index 89601d407..4d9425ba0 100644 --- a/wpa_supplicant/mesh_rsn.h +++ b/wpa_supplicant/mesh_rsn.h @@ -12,7 +12,8 @@ struct mesh_rsn { struct wpa_supplicant *wpa_s; struct wpa_authenticator *auth; - u8 mgtk[16]; + u8 mgtk[WPA_TK_MAX_LEN]; + size_t mgtk_len; #ifdef CONFIG_SAE struct wpabuf *sae_token; int sae_group_index;