mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-30 14:12:51 +01:00
eapol: Simplify install_tk callback
This commit is contained in:
parent
e93dd44607
commit
99cdb860c0
10
src/eapol.c
10
src/eapol.c
@ -1003,6 +1003,7 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex,
|
||||
const uint8_t *rsne;
|
||||
const uint8_t *optional_rsne = NULL;
|
||||
uint8_t gtk_key_index;
|
||||
enum ie_rsn_cipher_suite pairwise = sm->pairwise_cipher;
|
||||
|
||||
if (!eapol_verify_ptk_3_of_4(ek, sm->wpa_ie)) {
|
||||
handshake_failed(ifindex, sm, MPDU_REASON_CODE_UNSPECIFIED);
|
||||
@ -1100,6 +1101,8 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex,
|
||||
MPDU_REASON_CODE_INVALID_PAIRWISE_CIPHER);
|
||||
return;
|
||||
}
|
||||
|
||||
pairwise = override;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1141,8 +1144,11 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex,
|
||||
|
||||
sm->ptk_complete = true;
|
||||
|
||||
if (install_tk)
|
||||
install_tk(sm->ifindex, sm->aa, ptk->tk, rsne, sm->user_data);
|
||||
if (install_tk) {
|
||||
uint32_t cipher = ie_rsn_cipher_suite_to_cipher(pairwise);
|
||||
|
||||
install_tk(sm->ifindex, sm->aa, ptk->tk, cipher, sm->user_data);
|
||||
}
|
||||
|
||||
if (gtk && install_gtk) {
|
||||
uint32_t cipher =
|
||||
|
@ -100,7 +100,7 @@ typedef int (*eapol_tx_packet_func_t)(uint32_t ifindex, const uint8_t *aa,
|
||||
void *user_data);
|
||||
typedef bool (*eapol_get_nonce_func_t)(uint8_t nonce[]);
|
||||
typedef void (*eapol_install_tk_func_t)(uint32_t ifindex, const uint8_t *aa,
|
||||
const uint8_t *tk, const uint8_t *rsn,
|
||||
const uint8_t *tk, uint32_t cipher,
|
||||
void *user_data);
|
||||
typedef void (*eapol_install_gtk_func_t)(uint32_t ifindex, uint8_t key_index,
|
||||
const uint8_t *gtk, uint8_t gtk_len,
|
||||
|
29
src/wiphy.c
29
src/wiphy.c
@ -965,39 +965,20 @@ static unsigned int mlme_new_pairwise_key(struct netdev *netdev,
|
||||
}
|
||||
|
||||
static void wiphy_set_tk(uint32_t ifindex, const uint8_t *aa,
|
||||
const uint8_t *tk, const uint8_t *rsn,
|
||||
const uint8_t *tk, uint32_t cipher,
|
||||
void *user_data)
|
||||
{
|
||||
struct netdev *netdev = user_data;
|
||||
struct network *network = netdev->connected_network;
|
||||
struct wiphy *wiphy = netdev->wiphy;
|
||||
struct ie_rsn_info info;
|
||||
enum crypto_cipher cipher;
|
||||
int result;
|
||||
uint8_t tk_buf[32];
|
||||
|
||||
l_debug("");
|
||||
|
||||
if (rsn[0] == IE_TYPE_RSN)
|
||||
result = ie_parse_rsne_from_data(rsn, rsn[1] + 2, &info);
|
||||
else if (rsn[0] == IE_TYPE_VENDOR_SPECIFIC)
|
||||
result = ie_parse_wpa_from_data(rsn, rsn[1] + 2, &info);
|
||||
else
|
||||
result = -1;
|
||||
|
||||
if (result) {
|
||||
l_error("Can't parse the RSN");
|
||||
setting_keys_failed(netdev, MPDU_REASON_CODE_INVALID_IE);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (wiphy_select_cipher(wiphy, info.pairwise_ciphers)) {
|
||||
case IE_RSN_CIPHER_SUITE_CCMP:
|
||||
cipher = CRYPTO_CIPHER_CCMP;
|
||||
switch (cipher) {
|
||||
case CRYPTO_CIPHER_CCMP:
|
||||
memcpy(tk_buf, tk, 16);
|
||||
break;
|
||||
case IE_RSN_CIPHER_SUITE_TKIP:
|
||||
cipher = CRYPTO_CIPHER_TKIP;
|
||||
case CRYPTO_CIPHER_TKIP:
|
||||
/*
|
||||
* Swap the TX and RX MIC key portions for supplicant.
|
||||
* WPA_80211_v3_1_090922 doc's 3.3.4:
|
||||
@ -1014,7 +995,7 @@ static void wiphy_set_tk(uint32_t ifindex, const uint8_t *aa,
|
||||
memcpy(tk_buf + 24, tk + 16, 8);
|
||||
break;
|
||||
default:
|
||||
l_error("Unexpected cipher suite: %d", info.pairwise_ciphers);
|
||||
l_error("Unexpected cipher: %x", cipher);
|
||||
setting_keys_failed(netdev,
|
||||
MPDU_REASON_CODE_INVALID_PAIRWISE_CIPHER);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user