From 60957bee0a59ed781a168c987900db61aee6dfac Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Fri, 13 Jan 2023 03:15:56 +0200 Subject: [PATCH] [gsupplicant] Added missing KeyMgmt caps. JB#59693 --- include/gsupplicant_types.h | 8 ++++-- src/gsupplicant.c | 21 +++++++++++++-- src/gsupplicant_bss.c | 11 +++----- src/gsupplicant_interface.c | 18 +++---------- src/gsupplicant_p.h | 51 +++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 27 deletions(-) create mode 100644 src/gsupplicant_p.h diff --git a/include/gsupplicant_types.h b/include/gsupplicant_types.h index 557d222..17d3ab7 100644 --- a/include/gsupplicant_types.h +++ b/include/gsupplicant_types.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2015-2020 Jolla Ltd. - * Copyright (C) 2015-2020 Slava Monich + * Copyright (C) 2023 Slava Monich * * You may use this file under the terms of BSD license as follows: * @@ -66,7 +66,11 @@ typedef enum gsupplicant_keymgmt { GSUPPLICANT_KEYMGMT_WPA_EAP_SHA256 = (0x00000040), GSUPPLICANT_KEYMGMT_IEEE8021X = (0x00000080), GSUPPLICANT_KEYMGMT_WPA_NONE = (0x00000100), - GSUPPLICANT_KEYMGMT_WPS = (0x00000200) + GSUPPLICANT_KEYMGMT_WPS = (0x00000200), + GSUPPLICANT_KEYMGMT_SAE = (0x00000400), /* Since 1.0.27 */ + GSUPPLICANT_KEYMGMT_SAE_EXT_KEY = (0x00000800), /* Since 1.0.27 */ + GSUPPLICANT_KEYMGMT_FT_SAE = (0x00001000), /* Since 1.0.27 */ + GSUPPLICANT_KEYMGMT_FT_SAE_EXT_KEY = (0x00002000) /* Since 1.0.27 */ } GSUPPLICANT_KEYMGMT; typedef enum gsupplicant_protocol { diff --git a/src/gsupplicant.c b/src/gsupplicant.c index fcb673e..cb03484 100644 --- a/src/gsupplicant.c +++ b/src/gsupplicant.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2015-2021 Jolla Ltd. - * Copyright (C) 2015-2021 Slava Monich + * Copyright (C) 2015-2023 Slava Monich * * You may use this file under the terms of BSD license as follows: * @@ -190,7 +190,11 @@ static const GSupNameIntPair gsupplicant_keymgmt_suites [] = { { "wpa-eap-sha256", GSUPPLICANT_KEYMGMT_WPA_EAP_SHA256 }, { "ieee8021x", GSUPPLICANT_KEYMGMT_IEEE8021X }, { "wpa-none", GSUPPLICANT_KEYMGMT_WPA_NONE }, - { "wps", GSUPPLICANT_KEYMGMT_WPS } + { "wps", GSUPPLICANT_KEYMGMT_WPS }, + { "sae", GSUPPLICANT_KEYMGMT_SAE }, + { "sae-ext-key", GSUPPLICANT_KEYMGMT_SAE_EXT_KEY }, + { "ft-sae", GSUPPLICANT_KEYMGMT_FT_SAE }, + { "ft-sae-ext-key", GSUPPLICANT_KEYMGMT_FT_SAE_EXT_KEY } }; /*==========================================================================* @@ -890,6 +894,19 @@ gsupplicant_keymgmt_suite_name( gsupplicant_keymgmt_suites, G_N_ELEMENTS(gsupplicant_keymgmt_suites)); } +/*==========================================================================* + * Internal API + *==========================================================================*/ + +GSUPPLICANT_KEYMGMT +gsupplicant_parse_keymgmt_list( + const char* name, + GVariant* value) +{ + return gsupplicant_parse_bits_array(0, name, value, + gsupplicant_keymgmt_suites, G_N_ELEMENTS(gsupplicant_keymgmt_suites)); +} + /*==========================================================================* * Internals *==========================================================================*/ diff --git a/src/gsupplicant_bss.c b/src/gsupplicant_bss.c index 9c175fd..f078ecc 100644 --- a/src/gsupplicant_bss.c +++ b/src/gsupplicant_bss.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2015-2021 Jolla Ltd. - * Copyright (C) 2015-2021 Slava Monich + * Copyright (C) 2015-2023 Slava Monich * * You may use this file under the terms of BSD license as follows: * @@ -34,6 +34,7 @@ #include "gsupplicant_bss.h" #include "gsupplicant_interface.h" +#include "gsupplicant_p.h" #include "gsupplicant_util_p.h" #include "gsupplicant_dbus.h" #include "gsupplicant_log.h" @@ -481,13 +482,7 @@ gsupplicant_bss_parse_wpa( { GSupplicantBSSWPA* wpa = data; if (!g_strcmp0(name, "KeyMgmt")) { - static const GSupNameIntPair keymgmt_map [] = { - { "wpa-psk", GSUPPLICANT_KEYMGMT_WPA_PSK }, - { "wpa-eap", GSUPPLICANT_KEYMGMT_WPA_EAP }, - { "wpa-none", GSUPPLICANT_KEYMGMT_WPA_NONE } - }; - wpa->keymgmt = gsupplicant_parse_bits_array(0, name, value, - keymgmt_map, G_N_ELEMENTS(keymgmt_map)); + wpa->keymgmt = gsupplicant_parse_keymgmt_list(name, value); } else if (!g_strcmp0(name, "Pairwise")) { static const GSupNameIntPair pairwise_map [] = { { "ccmp", GSUPPLICANT_CIPHER_CCMP }, diff --git a/src/gsupplicant_interface.c b/src/gsupplicant_interface.c index 389aedd..ff636ae 100644 --- a/src/gsupplicant_interface.c +++ b/src/gsupplicant_interface.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2015-2021 Jolla Ltd. - * Copyright (C) 2015-2021 Slava Monich + * Copyright (C) 2015-2023 Slava Monich * * You may use this file under the terms of BSD license as follows: * @@ -36,6 +36,7 @@ #include "gsupplicant_network.h" #include "gsupplicant_bss.h" #include "gsupplicant.h" +#include "gsupplicant_p.h" #include "gsupplicant_util_p.h" #include "gsupplicant_dbus.h" #include "gsupplicant_log.h" @@ -1477,20 +1478,7 @@ gsupplicant_interface_parse_cap( caps->group = gsupplicant_parse_bits_array(0, name, value, group_map, G_N_ELEMENTS(group_map)); } else if (!g_strcmp0(name, "KeyMgmt")) { - static const GSupNameIntPair keymgmt_map [] = { - { "wpa-psk", GSUPPLICANT_KEYMGMT_WPA_PSK }, - { "wpa-ft-psk", GSUPPLICANT_KEYMGMT_WPA_FT_PSK }, - { "wpa-psk-sha256", GSUPPLICANT_KEYMGMT_WPA_PSK_SHA256 }, - { "wpa-eap", GSUPPLICANT_KEYMGMT_WPA_EAP }, - { "wpa-ft-eap", GSUPPLICANT_KEYMGMT_WPA_FT_EAP }, - { "wpa-eap-sha256", GSUPPLICANT_KEYMGMT_WPA_EAP_SHA256 }, - { "ieee8021x", GSUPPLICANT_KEYMGMT_IEEE8021X }, - { "wpa-none", GSUPPLICANT_KEYMGMT_WPA_NONE }, - { "wps", GSUPPLICANT_KEYMGMT_WPS }, - { "none", GSUPPLICANT_KEYMGMT_NONE } - }; - caps->keymgmt = gsupplicant_parse_bits_array(0, name, value, - keymgmt_map, G_N_ELEMENTS(keymgmt_map)); + caps->keymgmt = gsupplicant_parse_keymgmt_list(name, value); } else if (!g_strcmp0(name, "Protocol")) { static const GSupNameIntPair protocol_map [] = { { "rsn", GSUPPLICANT_PROTOCOL_RSN }, diff --git a/src/gsupplicant_p.h b/src/gsupplicant_p.h new file mode 100644 index 0000000..8530e63 --- /dev/null +++ b/src/gsupplicant_p.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2023 Slava Monich + * + * You may use this file under the terms of BSD license as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GSUPPLICANT_PRIVATE_H +#define GSUPPLICANT_PRIVATE_H + +#include "gsupplicant_types_p.h" + +GSUPPLICANT_KEYMGMT +gsupplicant_parse_keymgmt_list( + const char* name, + GVariant* value) + GSUPPLICANT_INTERNAL; + +#endif /* GSUPPLICANT_PRIVATE_H */ + +/* + * Local Variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */