From 8064cb599afd07c18105d868358fb7bf6d61c943 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 19 Sep 2018 11:30:35 -0700 Subject: [PATCH] ie: introduce IE_AKM_IS_SAE macro To prepare for FT over SAE, several case/if statements needed to include IE_RSN_AKM_SUITE_FT_OVER_SAE. Also a new macro was introduced to remove duplicate if statement code checking for both FT_OVER_SAE and SAE AKM's. --- src/eapol.c | 4 +++- src/ie.h | 4 ++++ src/netdev.c | 2 +- src/station.c | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/eapol.c b/src/eapol.c index e3ee8662..79b26f0e 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -81,6 +81,7 @@ bool eapol_calculate_mic(enum ie_rsn_akm_suite akm, const uint8_t *kck, case EAPOL_KEY_DESCRIPTOR_VERSION_AKM_DEFINED: switch (akm) { case IE_RSN_AKM_SUITE_SAE_SHA256: + case IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256: return cmac_aes(kck, 16, frame, frame_len, mic, 16); default: return false; @@ -123,6 +124,7 @@ bool eapol_verify_mic(enum ie_rsn_akm_suite akm, const uint8_t *kck, case EAPOL_KEY_DESCRIPTOR_VERSION_AKM_DEFINED: switch (akm) { case IE_RSN_AKM_SUITE_SAE_SHA256: + case IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256: checksum = l_checksum_new_cmac_aes(kck, 16); break; default: @@ -167,7 +169,7 @@ uint8_t *eapol_decrypt_key_data(enum ie_rsn_akm_suite akm, const uint8_t *kek, * type this will need to be expanded to handle the AKM types in * its own switch. */ - if (akm != IE_RSN_AKM_SUITE_SAE_SHA256) + if (!IE_AKM_IS_SAE(akm)) return NULL; /* Fall through */ diff --git a/src/ie.h b/src/ie.h index 72974a26..8448b858 100644 --- a/src/ie.h +++ b/src/ie.h @@ -252,6 +252,10 @@ enum ie_rsn_akm_suite { IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384 = 0x1000, }; +#define IE_AKM_IS_SAE(akm) \ + ((akm == IE_RSN_AKM_SUITE_SAE_SHA256) || \ + (akm == IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256)) + struct ie_tlv_iter { unsigned int max; unsigned int pos; diff --git a/src/netdev.c b/src/netdev.c index 1f6023f0..4604555e 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2510,7 +2510,7 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss, if (netdev->connected) return -EISCONN; - if (hs->akm_suite == IE_RSN_AKM_SUITE_SAE_SHA256) { + if (IE_AKM_IS_SAE(hs->akm_suite)) { netdev->sae_sm = sae_sm_new(hs, netdev_tx_sae_frame, netdev_sae_complete, netdev); } else { diff --git a/src/station.c b/src/station.c index df0b5948..74b64a19 100644 --- a/src/station.c +++ b/src/station.c @@ -380,6 +380,9 @@ static enum ie_rsn_akm_suite select_akm_suite(struct network *network, if (info->akm_suites & IE_RSN_AKM_SUITE_8021X) return IE_RSN_AKM_SUITE_8021X; } else if (security == SECURITY_PSK) { + if (info->akm_suites & IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256) + return IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256; + if (info->akm_suites & IE_RSN_AKM_SUITE_SAE_SHA256) return IE_RSN_AKM_SUITE_SAE_SHA256;