From 74e15c793bb0b6244f118f022cce9a2a67bf0f01 Mon Sep 17 00:00:00 2001 From: Joshua Grisham Date: Mon, 1 Sep 2025 01:37:06 +0200 Subject: [PATCH] sdcp: use GBytes for sdcp-data instead of GVariant --- libfprint/fp-sdcp-device-private.h | 12 ++++++------ libfprint/fp-sdcp-device.c | 21 ++++++++++----------- libfprint/fpi-sdcp-device.c | 30 +++--------------------------- 3 files changed, 19 insertions(+), 44 deletions(-) diff --git a/libfprint/fp-sdcp-device-private.h b/libfprint/fp-sdcp-device-private.h index 06cb4f0c..c1a988ac 100644 --- a/libfprint/fp-sdcp-device-private.h +++ b/libfprint/fp-sdcp-device-private.h @@ -24,12 +24,12 @@ typedef struct { - GBytes *host_private_key; - GBytes *host_public_key; - GBytes *host_random; - GBytes *reconnect_random; - GBytes *identify_nonce; - GVariant *data; + GBytes *host_private_key; + GBytes *host_public_key; + GBytes *host_random; + GBytes *reconnect_random; + GBytes *identify_nonce; + GBytes *data; } FpSdcpDevicePrivate; void fpi_sdcp_device_get_application_secret (FpSdcpDevice *self, diff --git a/libfprint/fp-sdcp-device.c b/libfprint/fp-sdcp-device.c index 5c0d02cc..695a6946 100644 --- a/libfprint/fp-sdcp-device.c +++ b/libfprint/fp-sdcp-device.c @@ -89,7 +89,7 @@ fp_sdcp_device_finalize (GObject *object) g_clear_pointer (&priv->host_random, g_bytes_unref); g_clear_pointer (&priv->reconnect_random, g_bytes_unref); g_clear_pointer (&priv->identify_nonce, g_bytes_unref); - g_clear_pointer (&priv->data, g_variant_unref); + g_clear_pointer (&priv->data, g_bytes_unref); G_OBJECT_CLASS (fp_sdcp_device_parent_class)->finalize (object); } @@ -106,7 +106,7 @@ fp_sdcp_device_get_property (GObject *object, switch (prop_id) { case PROP_SDCP_DATA: - g_value_set_variant (value, priv->data); + g_value_set_boxed (value, priv->data); break; default: @@ -126,8 +126,8 @@ fp_sdcp_device_set_property (GObject *object, switch (prop_id) { case PROP_SDCP_DATA: - g_clear_pointer (&priv->data, g_variant_unref); - priv->data = g_value_dup_variant (value); + g_clear_pointer (&priv->data, g_bytes_unref); + priv->data = g_value_dup_boxed (value); break; default: @@ -159,13 +159,12 @@ fp_sdcp_device_class_init (FpSdcpDeviceClass *klass) fp_device_class->identify = fp_sdcp_device_identify; properties[PROP_SDCP_DATA] = - g_param_spec_variant ("sdcp-data", - "SDCP Data", - "SDCP-related device data that should be persisted and used with the " - "device during the current system boot", - G_VARIANT_TYPE_ANY, - NULL, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE); + g_param_spec_boxed ("sdcp-data", + "SDCP Data", + "SDCP-related device data that should be persisted and used with the " + "device during the current system boot", + G_TYPE_BYTES, + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE); g_object_class_install_properties (object_class, N_PROPS, properties); diff --git a/libfprint/fpi-sdcp-device.c b/libfprint/fpi-sdcp-device.c index e714f288..0bc3abcf 100644 --- a/libfprint/fpi-sdcp-device.c +++ b/libfprint/fpi-sdcp-device.c @@ -151,10 +151,7 @@ void fpi_sdcp_device_get_application_secret (FpSdcpDevice *self, GBytes **application_secret) { - g_autoptr(GVariant) data = NULL; - g_autoptr(GVariant) application_secret_var = NULL; - const guint8 *application_secret_data; - gsize application_secret_len = 0; + GBytes *data = NULL; g_return_if_fail (*application_secret == NULL); @@ -163,37 +160,16 @@ fpi_sdcp_device_get_application_secret (FpSdcpDevice *self, if (!data) return; - if (!g_variant_check_format_string (data, "(@ay)", FALSE)) - { - fp_warn ("SDCP data is not in expected format."); - return; - } - - g_variant_get (data, "(@ay)", &application_secret_var); - - application_secret_data = g_variant_get_fixed_array (application_secret_var, - &application_secret_len, - sizeof (guint8)); - - *application_secret = g_bytes_new (application_secret_data, application_secret_len); + *application_secret = g_steal_pointer (&data); } void fpi_sdcp_device_set_application_secret (FpSdcpDevice *self, GBytes *application_secret) { - GVariant *application_secret_var; - GVariant *data; - g_return_if_fail (application_secret); - application_secret_var = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, - g_bytes_get_data (application_secret, NULL), - g_bytes_get_size (application_secret), - sizeof (guint8)); - data = g_variant_new ("(@ay)", application_secret_var); - - g_object_set (G_OBJECT (self), "sdcp-data", data, NULL); + g_object_set (G_OBJECT (self), "sdcp-data", application_secret, NULL); } void