3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2025-01-03 19:02:34 +01:00

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.
This commit is contained in:
Andrew Zaborowski 2018-09-22 18:48:16 +02:00 committed by Denis Kenzior
parent 7c779956ac
commit e4873dea5a

View File

@ -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, &gtk_len, gtk_oui);
const uint8_t *gtk = find_kde(data, data_len, &gtk_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;