mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
sdcp: use GBytes for sdcp-data instead of GVariant
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user