mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
nl80211: added verifier/parser for GET_KEY
AdHoc will also need the same functionality to verify and parse the key sequence from GET_KEY. This block of code was moved from AP's GET_KEY callback into nl80211_parse_get_key_seq.
This commit is contained in:
parent
60aba7114e
commit
5e5caedb90
41
src/ap.c
41
src/ap.c
@ -453,48 +453,15 @@ error:
|
||||
static void ap_gtk_query_cb(struct l_genl_msg *msg, void *user_data)
|
||||
{
|
||||
struct sta_state *sta = user_data;
|
||||
struct l_genl_attr attr, nested;
|
||||
uint16_t type, len;
|
||||
const void *data;
|
||||
const void *gtk_rsc;
|
||||
|
||||
sta->gtk_query_cmd_id = 0;
|
||||
|
||||
if (l_genl_msg_get_error(msg) < 0 || !l_genl_attr_init(&attr, msg)) {
|
||||
l_error("GET_KEY failed for the GTK: %i",
|
||||
l_genl_msg_get_error(msg));
|
||||
gtk_rsc = nl80211_parse_get_key_seq(msg);
|
||||
if (!gtk_rsc)
|
||||
goto error;
|
||||
}
|
||||
|
||||
while (l_genl_attr_next(&attr, &type, &len, &data)) {
|
||||
if (type != NL80211_ATTR_KEY)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (type != NL80211_ATTR_KEY || !l_genl_attr_recurse(&attr, &nested)) {
|
||||
l_error("Can't recurse into ATTR_KEY in GET_KEY reply");
|
||||
goto error;
|
||||
}
|
||||
|
||||
while (l_genl_attr_next(&nested, &type, &len, &data)) {
|
||||
if (type != NL80211_KEY_SEQ)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (type != NL80211_KEY_SEQ) {
|
||||
l_error("KEY_SEQ not returned in GET_KEY reply");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (len != 6) {
|
||||
l_error("KEY_SEQ length != 6 in GET_KEY reply");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ap_start_rsna(sta, data);
|
||||
ap_start_rsna(sta, gtk_rsc);
|
||||
return;
|
||||
|
||||
error:
|
||||
|
@ -133,3 +133,47 @@ struct l_genl_msg *nl80211_build_get_key(uint32_t ifindex, uint8_t key_index)
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
const void *nl80211_parse_get_key_seq(struct l_genl_msg *msg)
|
||||
{
|
||||
struct l_genl_attr attr, nested;
|
||||
uint16_t type, len;
|
||||
const void *data;
|
||||
|
||||
if (l_genl_msg_get_error(msg) < 0 || !l_genl_attr_init(&attr, msg)) {
|
||||
l_error("GET_KEY failed for the GTK: %i",
|
||||
l_genl_msg_get_error(msg));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (l_genl_attr_next(&attr, &type, &len, &data)) {
|
||||
if (type != NL80211_ATTR_KEY)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (type != NL80211_ATTR_KEY || !l_genl_attr_recurse(&attr, &nested)) {
|
||||
l_error("Can't recurse into ATTR_KEY in GET_KEY reply");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (l_genl_attr_next(&nested, &type, &len, &data)) {
|
||||
if (type != NL80211_KEY_SEQ)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (type != NL80211_KEY_SEQ) {
|
||||
l_error("KEY_SEQ not returned in GET_KEY reply");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (len != 6) {
|
||||
l_error("KEY_SEQ length != 6 in GET_KEY reply");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -39,3 +39,5 @@ struct l_genl_msg *nl80211_build_set_station_unauthorized(uint32_t ifindex,
|
||||
struct l_genl_msg *nl80211_build_set_key(uint32_t ifindex, uint8_t key_index);
|
||||
|
||||
struct l_genl_msg *nl80211_build_get_key(uint32_t ifindex, uint8_t key_index);
|
||||
|
||||
const void *nl80211_parse_get_key_seq(struct l_genl_msg *msg);
|
||||
|
Loading…
Reference in New Issue
Block a user