[libnma/ac/owe] wireless security: include owe




commit b86ede626a7f6a1c08dc068a70b48bb50b635b57
Author: Ana Cabral <acabral redhat com>
Date:   Mon Mar 7 16:08:50 2022 -0300

    wireless security: include owe
    
    https://gitlab.gnome.org/GNOME/libnma/-/issues/9
    
    https://gitlab.gnome.org/GNOME/libnma/-/merge_requests/24

 Makefile.am             |   2 +
 src/libnma.ver          |   5 ++
 src/nma-version.h.in    |   7 +++
 src/nma-wifi-dialog.c   |  14 +++++
 src/nma-ws/meson.build  |   2 +
 src/nma-ws/nma-ws-owe.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/nma-ws/nma-ws-owe.h |  26 +++++++++
 src/nma-ws/nma-ws.h     |   1 +
 8 files changed, 205 insertions(+)
---
diff --git a/Makefile.am b/Makefile.am
index b60baf41..1f755e9b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -172,6 +172,7 @@ libnma_h_pub = \
        src/nma-ws/nma-ws-dynamic-wep.h \
        src/nma-ws/nma-ws.h \
        src/nma-ws/nma-ws-leap.h \
+       src/nma-ws/nma-ws-owe.h \
        src/nma-ws/nma-ws-sae.h \
        src/nma-ws/nma-ws-wep-key.h \
        src/nma-ws/nma-ws-wpa-eap.h \
@@ -200,6 +201,7 @@ libnma_c_real = \
        src/nma-ws/nma-ws-dynamic-wep.c \
        src/nma-ws/nma-ws-helpers.c \
        src/nma-ws/nma-ws-leap.c \
+       src/nma-ws/nma-ws-owe.c \
        src/nma-ws/nma-ws-sae.c \
        src/nma-ws/nma-ws-wep-key.c \
        src/nma-ws/nma-ws-wpa-eap.c \
diff --git a/src/libnma.ver b/src/libnma.ver
index 3e444d44..dd9e33e7 100644
--- a/src/libnma.ver
+++ b/src/libnma.ver
@@ -134,3 +134,8 @@ libnma_1_8_28 {
        nma_ws_wpa_psk_get_type;
        nma_ws_wpa_psk_new;
 } libnma_1_8_22;
+
+libnma_1_8_36 {
+       nma_ws_owe_get_type;
+       nma_ws_owe_new;
+} libnma_1_8_28;
diff --git a/src/nma-version.h.in b/src/nma-version.h.in
index 9c511da6..d2be7b9f 100644
--- a/src/nma-version.h.in
+++ b/src/nma-version.h.in
@@ -62,6 +62,7 @@
 #define NMA_VERSION_1_8_26 (NMA_ENCODE_VERSION (1, 8, 26))
 #define NMA_VERSION_1_8_28 (NMA_ENCODE_VERSION (1, 8, 28))
 #define NMA_VERSION_1_8_34 (NMA_ENCODE_VERSION (1, 8, 34))
+#define NMA_VERSION_1_8_36 (NMA_ENCODE_VERSION (1, 8, 36))
 
 /* For releases, NMA_API_VERSION is equal to NMA_VERSION.
  *
@@ -150,4 +151,10 @@
 # define NMA_AVAILABLE_IN_1_8_34
 #endif
 
+#if NMA_VERSION_MAX_ALLOWED < NMA_VERSION_1_8_36
+# define NMA_AVAILABLE_IN_1_8_36            G_UNAVAILABLE(1.8,36)
+#else
+# define NMA_AVAILABLE_IN_1_8_36
+#endif
+
 #endif  /* NMA_VERSION_H */
diff --git a/src/nma-wifi-dialog.c b/src/nma-wifi-dialog.c
index 60793fc6..633b7dea 100644
--- a/src/nma-wifi-dialog.c
+++ b/src/nma-wifi-dialog.c
@@ -686,6 +686,9 @@ get_default_type_for_security (NMSettingWirelessSecurity *sec,
        if (!strcmp (key_mgmt, "none"))
                return NMU_SEC_STATIC_WEP;
 
+       if (!strcmp (key_mgmt, "owe"))
+           return NMU_SEC_OWE;
+
        if (   !strcmp (key_mgmt, "ieee8021x")
            && (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY))) {
                if (auth_alg && !strcmp (auth_alg, "leap"))
@@ -1018,6 +1021,17 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only,
                item++;
        }
 
+       if (security_valid (NMU_SEC_OWE, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
+               NMAWsOwe *ws_owe;
+
+               ws_owe = nma_ws_owe_new (priv->connection);
+               add_security_item (self, NMA_WS (ws_owe), sec_model,
+                                                  &iter, _("Enhanced Open"));
+               if (active < 0 && default_type == NMU_SEC_OWE)
+                       active = item;
+               item++;
+       }
+
        gtk_combo_box_set_model (GTK_COMBO_BOX (priv->sec_combo), GTK_TREE_MODEL (sec_model));
        gtk_combo_box_set_active (GTK_COMBO_BOX (priv->sec_combo), active < 0 ? 0 : (guint32) active);
        g_object_unref (G_OBJECT (sec_model));
diff --git a/src/nma-ws/meson.build b/src/nma-ws/meson.build
index 7b94d4be..1e971ea2 100644
--- a/src/nma-ws/meson.build
+++ b/src/nma-ws/meson.build
@@ -19,6 +19,7 @@ nma_ws_headers = files(
   'nma-ws-dynamic-wep.h',
   'nma-ws.h',
   'nma-ws-leap.h',
+  'nma-ws-owe.h',
   'nma-ws-sae.h',
   'nma-ws-wep-key.h',
   'nma-ws-wpa-eap.h',
@@ -38,6 +39,7 @@ nma_ws_sources = files(
   'nma-ws-dynamic-wep.c',
   'nma-ws-helpers.c',
   'nma-ws-leap.c',
+  'nma-ws-owe.c',
   'nma-ws-sae.c',
   'nma-ws-wep-key.c',
   'nma-ws-wpa-eap.c',
diff --git a/src/nma-ws/nma-ws-owe.c b/src/nma-ws/nma-ws-owe.c
new file mode 100644
index 00000000..9a9e983e
--- /dev/null
+++ b/src/nma-ws/nma-ws-owe.c
@@ -0,0 +1,148 @@
+#include "nm-default.h"
+#include "nma-private.h"
+
+#include "nma-ws.h"
+#include "nma-ws-private.h"
+#include "nma-ws-owe.h"
+
+struct _NMAWsOwe {
+       GtkGrid parent;
+
+       NMConnection *connection;
+};
+
+struct _NMAWsOweClass {
+       GtkGridClass parent;
+};
+
+static void nma_ws_interface_init (NMAWsInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (NMAWsOwe, nma_ws_owe, GTK_TYPE_GRID,
+                         G_IMPLEMENT_INTERFACE (NMA_TYPE_WS, nma_ws_interface_init))
+
+enum {
+       PROP_0,
+       PROP_CONNECTION,
+       PROP_SECRETS_ONLY,
+       PROP_LAST
+};
+
+static gboolean
+validate (NMAWs *ws, GError **error)
+{
+       return TRUE;
+}
+
+static void
+add_to_size_group (NMAWs *ws, GtkSizeGroup *group)
+{
+}
+
+static void
+fill_connection (NMAWs *ws, NMConnection *connection)
+{
+       NMSetting *s_wireless_sec;
+
+       /* Blow away the old security setting by adding a clear one */
+       s_wireless_sec = nm_setting_wireless_security_new ();
+       g_object_set (s_wireless_sec,
+                             NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "owe",
+                                 NULL);
+
+       nm_connection_add_setting (connection, s_wireless_sec);
+}
+
+static void
+update_secrets (NMAWs *ws, NMConnection *connection)
+{
+}
+
+static void
+get_property (GObject *object,
+              guint prop_id,
+              GValue *value,
+              GParamSpec *pspec)
+{
+       NMAWsOwe *self = NMA_WS_OWE (object);
+
+       switch (prop_id) {
+       case PROP_CONNECTION:
+               g_value_set_object (value, self->connection);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+set_property (GObject *object,
+              guint prop_id,
+              const GValue *value,
+              GParamSpec *pspec)
+{
+       NMAWsOwe *self = NMA_WS_OWE (object);
+
+       switch (prop_id) {
+       case PROP_CONNECTION:
+               self->connection = g_value_dup_object (value);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+nma_ws_owe_init (NMAWsOwe *self)
+{
+}
+
+static void
+nma_ws_interface_init (NMAWsInterface *iface)
+{
+       iface->validate = validate;
+       iface->add_to_size_group = add_to_size_group;
+       iface->fill_connection = fill_connection;
+       iface->update_secrets = update_secrets;
+       iface->adhoc_compatible = FALSE;
+       iface->hotspot_compatible = TRUE;
+}
+
+static void
+constructed (GObject *object)
+{
+       G_OBJECT_CLASS (nma_ws_owe_parent_class)->constructed (object);
+}
+
+NMAWsOwe *
+nma_ws_owe_new (NMConnection *connection)
+{
+       return g_object_new (NMA_TYPE_WS_OWE,
+                            "connection", connection,
+                            NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+       NMAWsOwe *self = NMA_WS_OWE (object);
+
+       g_clear_object (&self->connection);
+
+       G_OBJECT_CLASS (nma_ws_owe_parent_class)->dispose (object);
+}
+
+static void
+nma_ws_owe_class_init (NMAWsOweClass *klass){
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       object_class->get_property = get_property;
+       object_class->set_property = set_property;
+       object_class->constructed = constructed;
+       object_class->dispose = dispose;
+
+       g_object_class_override_property (object_class,
+                                             PROP_CONNECTION, "connection");
+
+}
diff --git a/src/nma-ws/nma-ws-owe.h b/src/nma-ws/nma-ws-owe.h
new file mode 100644
index 00000000..1772393f
--- /dev/null
+++ b/src/nma-ws/nma-ws-owe.h
@@ -0,0 +1,26 @@
+#ifndef NMA_WS_OWE_H
+#define NMA_WS_OWE_H
+
+#include "nma-version.h"
+
+G_BEGIN_DECLS
+
+typedef struct _NMAWsOwe NMAWsOwe;
+typedef struct _NMAWsOweClass NMAWsOweClass;
+
+#define NMA_TYPE_WS_OWE            (nma_ws_owe_get_type ())
+#define NMA_WS_OWE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_WS_OWE, NMAWsOwe))
+#define NMA_WS_OWE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_WS_OWE, NMAWsOweClass))
+#define NMA_IS_WS_OWE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_OWE))
+#define NMA_IS_OWE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMA_TYPE_WS_OWE))
+#define NMA_WS_OWE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_WS_OWE, NMAWsOweClass))
+
+NMA_AVAILABLE_IN_1_8_36
+GType nma_ws_owe_get_type (void);
+
+NMA_AVAILABLE_IN_1_8_36
+NMAWsOwe *nma_ws_owe_new (NMConnection *connection);
+
+G_END_DECLS
+
+#endif /* NMA_WS_OWE_H */
diff --git a/src/nma-ws/nma-ws.h b/src/nma-ws/nma-ws.h
index e046cc11..752f76cd 100644
--- a/src/nma-ws/nma-ws.h
+++ b/src/nma-ws/nma-ws.h
@@ -49,6 +49,7 @@ G_END_DECLS
 #include "nma-ws-802-1x.h"
 #include "nma-ws-dynamic-wep.h"
 #include "nma-ws-leap.h"
+#include "nma-ws-owe.h"
 #include "nma-ws-sae.h"
 #include "nma-ws-wep-key.h"
 #include "nma-ws-wpa-eap.h"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]