mesh: Add variable length MTK support

This is needed as a part in enabling support for different pairwise
ciphers in mesh.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2016-06-18 14:35:35 +03:00
parent 846201dff7
commit b02f4d058c
3 changed files with 7 additions and 4 deletions

View file

@ -85,7 +85,8 @@ struct sta_info {
u8 my_nonce[WPA_NONCE_LEN]; u8 my_nonce[WPA_NONCE_LEN];
u8 peer_nonce[WPA_NONCE_LEN]; u8 peer_nonce[WPA_NONCE_LEN];
u8 aek[32]; /* SHA256 digest length */ u8 aek[32]; /* SHA256 digest length */
u8 mtk[16]; u8 mtk[WPA_TK_MAX_LEN];
size_t mtk_len;
u8 mgtk[16]; u8 mgtk[16];
u8 sae_auth_retry; u8 sae_auth_retry;
#endif /* CONFIG_MESH */ #endif /* CONFIG_MESH */

View file

@ -793,8 +793,10 @@ static void mesh_mpm_plink_estab(struct wpa_supplicant *wpa_s,
MAC2STR(sta->addr)); MAC2STR(sta->addr));
if (conf->security & MESH_CONF_SEC_AMPE) { if (conf->security & MESH_CONF_SEC_AMPE) {
wpa_hexdump_key(MSG_DEBUG, "mesh: MTK", sta->mtk, sta->mtk_len);
/* TODO: support for other ciphers */
wpa_drv_set_key(wpa_s, WPA_ALG_CCMP, sta->addr, 0, 0, wpa_drv_set_key(wpa_s, WPA_ALG_CCMP, sta->addr, 0, 0,
seq, sizeof(seq), sta->mtk, sizeof(sta->mtk)); seq, sizeof(seq), sta->mtk, sta->mtk_len);
wpa_drv_set_key(wpa_s, WPA_ALG_CCMP, sta->addr, 1, 0, wpa_drv_set_key(wpa_s, WPA_ALG_CCMP, sta->addr, 1, 0,
seq, sizeof(seq), seq, sizeof(seq),
sta->mgtk, sizeof(sta->mgtk)); sta->mgtk, sizeof(sta->mgtk));
@ -802,7 +804,6 @@ static void mesh_mpm_plink_estab(struct wpa_supplicant *wpa_s,
seq, sizeof(seq), seq, sizeof(seq),
sta->mgtk, sizeof(sta->mgtk)); sta->mgtk, sizeof(sta->mgtk));
wpa_hexdump_key(MSG_DEBUG, "mtk:", sta->mtk, sizeof(sta->mtk));
wpa_hexdump_key(MSG_DEBUG, "mgtk:", wpa_hexdump_key(MSG_DEBUG, "mgtk:",
sta->mgtk, sizeof(sta->mgtk)); sta->mgtk, sizeof(sta->mgtk));
} }

View file

@ -445,9 +445,10 @@ int mesh_rsn_derive_mtk(struct wpa_supplicant *wpa_s, struct sta_info *sta)
ptr += ETH_ALEN; ptr += ETH_ALEN;
os_memcpy(ptr, max, ETH_ALEN); os_memcpy(ptr, max, ETH_ALEN);
sta->mtk_len = wpa_cipher_key_len(WPA_CIPHER_CCMP);
sha256_prf(sta->sae->pmk, SAE_PMK_LEN, sha256_prf(sta->sae->pmk, SAE_PMK_LEN,
"Temporal Key Derivation", context, sizeof(context), "Temporal Key Derivation", context, sizeof(context),
sta->mtk, sizeof(sta->mtk)); sta->mtk, sta->mtk_len);
return 0; return 0;
} }