From e4873dea5a09d9d277f0ca11e11c3ce9c0a2c946 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Sat, 22 Sep 2018 18:48:16 +0200 Subject: [PATCH] handshake: Use enum handshake_kde in find_kde() Since we have all the KDE types defined in enum handshake_kde use that instead of uint8_t buffers containing the same values. --- src/handshake.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/handshake.c b/src/handshake.c index c17aac85..c7784f46 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -553,7 +553,7 @@ bool handshake_util_ap_ie_matches(const uint8_t *msg_ie, } static const uint8_t *find_kde(const uint8_t *data, size_t data_len, - size_t *out_len, const unsigned char *oui) + size_t *out_len, enum handshake_kde selector) { struct ie_tlv_iter iter; const uint8_t *result; @@ -571,7 +571,7 @@ static const uint8_t *find_kde(const uint8_t *data, size_t data_len, /* Check OUI */ result = ie_tlv_iter_get_data(&iter); - if (memcmp(result, oui, 4)) + if (l_get_be32(result) != selector) continue; if (out_len) @@ -586,9 +586,9 @@ static const uint8_t *find_kde(const uint8_t *data, size_t data_len, const uint8_t *handshake_util_find_gtk_kde(const uint8_t *data, size_t data_len, size_t *out_gtk_len) { - static const unsigned char gtk_oui[] = { 0x00, 0x0f, 0xac, 0x01 }; size_t gtk_len; - const uint8_t *gtk = find_kde(data, data_len, >k_len, gtk_oui); + const uint8_t *gtk = find_kde(data, data_len, >k_len, + HANDSHAKE_KDE_GTK); if (!gtk) return NULL; @@ -613,9 +613,9 @@ const uint8_t *handshake_util_find_igtk_kde(const uint8_t *data, size_t data_len, size_t *out_igtk_len) { - static const unsigned char igtk_oui[] = { 0x00, 0x0f, 0xac, 0x09 }; size_t igtk_len; - const uint8_t *igtk = find_kde(data, data_len, &igtk_len, igtk_oui); + const uint8_t *igtk = find_kde(data, data_len, &igtk_len, + HANDSHAKE_KDE_IGTK); if (!igtk) return NULL; @@ -639,11 +639,10 @@ const uint8_t *handshake_util_find_igtk_kde(const uint8_t *data, const uint8_t *handshake_util_find_pmkid_kde(const uint8_t *data, size_t data_len) { - static const unsigned char pmkid_oui[] = { 0x00, 0x0f, 0xac, 0x04 }; const uint8_t *pmkid; size_t pmkid_len; - pmkid = find_kde(data, data_len, &pmkid_len, pmkid_oui); + pmkid = find_kde(data, data_len, &pmkid_len, HANDSHAKE_KDE_PMKID); if (pmkid && pmkid_len != 16) return NULL;